lib/hamlit/cli.rb in hamlit-2.8.3 vs lib/hamlit/cli.rb in hamlit-2.8.4
- old
+ new
@@ -53,12 +53,20 @@
if options[:require]
require options[:require]
end
end
+ def read_file(file)
+ if file == '-'
+ STDIN.read
+ else
+ File.read(file)
+ end
+ end
+
def generate_code(file)
- template = File.read(file)
+ template = read_file(file)
if options[:actionview]
require 'action_view'
require 'action_view/base'
require 'hamlit/rails_template'
handler = Hamlit::RailsTemplate.new
@@ -75,10 +83,10 @@
Hamlit::Engine.new(engine_options).call(template)
end
end
def generate_ast(file)
- template = File.read(file)
+ template = read_file(file)
Hamlit::Parser.new(engine_options).call(template)
end
def generate_temple(file)
ast = generate_ast(file)