Class: ComponentEmbeddedRuby::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/component_embedded_ruby/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Template

Returns a new instance of Template.



3
4
5
# File 'lib/component_embedded_ruby/template.rb', line 3

def initialize(template)
  @template = template
end

Instance Method Details

#to_rubyObject



7
8
9
10
11
# File 'lib/component_embedded_ruby/template.rb', line 7

def to_ruby
  tokens = Lexer.new(@template).lex
  nodes = Parser.parse(tokens)
  Renderer.new(nodes).to_ruby
end

#to_s(binding: TOPLEVEL_BINDING) ⇒ Object



13
14
15
# File 'lib/component_embedded_ruby/template.rb', line 13

def to_s(binding: TOPLEVEL_BINDING)
  eval(to_ruby, binding)
end