class Temple::CoffeeScript::Generator

Public Instance Methods

call(exp) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 8
def call(exp)
  @indent = options[:indent]
  compile [:multi, [:code, "#{buffer} = ''"], exp, [:code, "#{buffer}"]]
end
concat(str) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 40
def concat(str)
  indent "#{buffer} += #{str}"
end
indent(str, indent = @indent) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 44
def indent(str, indent = @indent)
  "  " * indent + str
end
on_capture(name, exp) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 36
def on_capture(name, exp)
  self.class.new(:buffer => name, :indent => @indent).call(exp)
end
on_code(code) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 25
def on_code(code)
  indent(code)
end
on_dynamic(code) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 21
def on_dynamic(code)
  concat(code)
end
on_indent(exp) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 29
def on_indent(exp)
  @indent += 1
  compile(exp)
ensure
  @indent -= 1
end
on_multi(*exp) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 13
def on_multi(*exp)
  exp.map {|e| compile(e) }.join("\n")
end
on_static(text) click to toggle source
# File lib/temple/coffee_script/generators.rb, line 17
def on_static(text)
  concat(JSON.generate(text, :quirks_mode => true))
end