lib/hamlit/cli.rb in hamlit-2.0.2 vs lib/hamlit/cli.rb in hamlit-2.1.0

- old
+ new

@@ -2,11 +2,14 @@ require 'thor' module Hamlit class CLI < Thor desc 'render HAML', 'Render haml template' + option :load_path, type: :string, aliases: %w[-I] + option :require, type: :string, aliases: %w[-r] def render(file) + process_load_options code = generate_code(file) puts eval(code) end desc 'compile HAML', 'Show compile result' @@ -24,9 +27,21 @@ def parse(file) pp generate_ast(file) end private + + def process_load_options + if options[:load_path] + options[:load_path].split(':').each do |dir| + $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) + end + end + + if options[:require] + require options[:require] + end + end def generate_code(file) template = File.read(file) if options[:actionview] require 'action_view'