Class: ComponentEmbeddedRuby::Template
- Inherits:
-
Object
- Object
- ComponentEmbeddedRuby::Template
- Defined in:
- lib/component_embedded_ruby/template.rb
Instance Method Summary collapse
-
#initialize(template) ⇒ Template
constructor
A new instance of Template.
- #to_ruby ⇒ Object
- #to_s(binding: TOPLEVEL_BINDING) ⇒ Object
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_ruby ⇒ Object
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 |