Class: Hamlit::Compiler

Inherits:
Object show all
Defined in:
lib/hamlit/compiler.rb,
lib/hamlit/compiler/tag_compiler.rb,
lib/hamlit/compiler/script_compiler.rb,
lib/hamlit/compiler/comment_compiler.rb,
lib/hamlit/compiler/doctype_compiler.rb,
lib/hamlit/compiler/children_compiler.rb,
lib/hamlit/compiler/silent_script_compiler.rb

Defined Under Namespace

Classes: ChildrenCompiler, CommentCompiler, DoctypeCompiler, ScriptCompiler, SilentScriptCompiler, TagCompiler

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Compiler

Returns a new instance of Compiler.



13
14
15
16
17
18
19
20
21
22
# File 'lib/hamlit/compiler.rb', line 13

def initialize(options = {})
  identity                = Identity.new
  @children_compiler      = ChildrenCompiler.new
  @comment_compiler       = CommentCompiler.new
  @doctype_compiler       = DoctypeCompiler.new(options)
  @filter_compiler        = Filters.new(options)
  @script_compiler        = ScriptCompiler.new(identity)
  @silent_script_compiler = SilentScriptCompiler.new
  @tag_compiler           = TagCompiler.new(identity, options)
end

Instance Method Details

#call(ast) ⇒ Object



24
25
26
27
28
29
# File 'lib/hamlit/compiler.rb', line 24

def call(ast)
  return runtime_error(ast) if ast.is_a?(HamlError)
  compile(ast)
rescue Error => e
  runtime_error(e)
end