1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/hamlit/engine.rb

36 lines
731 B
Ruby
Raw Normal View History

2015-10-06 23:14:45 +09:00
require 'temple'
require 'hamlit/compiler'
require 'hamlit/parser'
module Hamlit
class Engine < Temple::Engine
define_options(
generator: Temple::Generators::ArrayBuffer,
format: :html,
attr_quote: "'",
escape_html: true,
pretty: false,
)
use Parser
use Compiler
html :Pretty
filter :Escapable
filter :ControlFlow
filter :MultiFlattener
filter :StaticMerger
use :Generator, -> { options[:generator] }
end
2015-10-07 00:18:41 +09:00
class HamlEngine
def initialize(template, options = {})
@template = template
@options = options
end
def render(scope = Object.new, locals = {}, &block)
eval Engine.new.call(@template)
end
end
2015-10-06 23:14:45 +09:00
end