Sha256: 9215d6b9b8ff562612c60a6c5e98e71434aef02eaacea5a422e11b96646837fc

Contents?: true

Size: 726 Bytes

Versions: 7

Compression:

Stored size: 726 Bytes

Contents

require 'faml'
require 'thor'

module Faml
  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 faml AST'
    def parse(file)
      require 'pp'
      pp parse_file(file)
    end

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

    private

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
faml-0.2.6 lib/faml/cli.rb
faml-0.2.5 lib/faml/cli.rb
faml-0.2.4 lib/faml/cli.rb
faml-0.2.3 lib/faml/cli.rb
faml-0.2.2 lib/faml/cli.rb
faml-0.2.1 lib/faml/cli.rb
faml-0.2.0 lib/faml/cli.rb