mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Use pretty mode by default in CLI
This commit is contained in:
parent
473c55f7ba
commit
0b971624e8
1 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,8 @@ require 'thor'
|
||||||
|
|
||||||
module Hamlit
|
module Hamlit
|
||||||
class CLI < Thor
|
class CLI < Thor
|
||||||
|
class_option :style, type: :string, aliases: ['-t'], default: 'pretty'
|
||||||
|
|
||||||
desc 'render HAML', 'Render haml template'
|
desc 'render HAML', 'Render haml template'
|
||||||
def render(file)
|
def render(file)
|
||||||
code = generate_code(file)
|
code = generate_code(file)
|
||||||
|
@ -23,7 +25,7 @@ module Hamlit
|
||||||
|
|
||||||
def generate_code(file)
|
def generate_code(file)
|
||||||
template = File.read(file)
|
template = File.read(file)
|
||||||
Hamlit::Engine.new.call(template)
|
Hamlit::Engine.new(engine_options).call(template)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_ast(file)
|
def generate_ast(file)
|
||||||
|
@ -31,6 +33,10 @@ module Hamlit
|
||||||
Hamlit::Parser.new.call(template)
|
Hamlit::Parser.new.call(template)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def engine_options
|
||||||
|
{ pretty: options['style'] == 'pretty' }
|
||||||
|
end
|
||||||
|
|
||||||
# Flexible default_task, compatible with haml's CLI
|
# Flexible default_task, compatible with haml's CLI
|
||||||
def method_missing(*args)
|
def method_missing(*args)
|
||||||
return super(*args) if args.length > 1
|
return super(*args) if args.length > 1
|
||||||
|
|
Loading…
Reference in a new issue