Sha256: 0f3643439588c8da46d80d5d9fe3866f6db7b036b28c983d0efeceb002e4422c

Contents?: true

Size: 752 Bytes

Versions: 11

Compression:

Stored size: 752 Bytes

Contents

require 'fast_haml'
require 'thor'

module FastHaml
  class CLI < Thor
    desc 'render FILE', 'Render haml template'
    def render(file)
      puts eval(compile_file(file))
    end

    desc 'compile FILE', 'Compile haml template'
    def compile(file)
      puts compile_file(file)
    end

    desc 'parse FILE', 'Render fast_haml AST'
    def parse(file)
      require 'pp'
      pp parse_file(file)
    end

    desc 'temple FILE', 'Render temple AST'
    def temple(file)
      require 'pp'
      pp FastHaml::Compiler.new.call(parse_file(file))
    end

    private

    def compile_file(file)
      FastHaml::Engine.new.call(File.read(file))
    end

    def parse_file(file)
      FastHaml::Parser.new.call(File.read(file))
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fast_haml-0.1.10 lib/fast_haml/cli.rb
fast_haml-0.1.9 lib/fast_haml/cli.rb
fast_haml-0.1.8 lib/fast_haml/cli.rb
fast_haml-0.1.7 lib/fast_haml/cli.rb
fast_haml-0.1.6 lib/fast_haml/cli.rb
fast_haml-0.1.5 lib/fast_haml/cli.rb
fast_haml-0.1.4 lib/fast_haml/cli.rb
fast_haml-0.1.3 lib/fast_haml/cli.rb
fast_haml-0.1.2 lib/fast_haml/cli.rb
fast_haml-0.1.1 lib/fast_haml/cli.rb
fast_haml-0.1.0 lib/fast_haml/cli.rb