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.
5 6 7 |
# File 'lib/component_embedded_ruby/template.rb', line 5 def initialize(template) @template = template end |
Instance Method Details
#to_ruby ⇒ Object
9 10 11 12 13 |
# File 'lib/component_embedded_ruby/template.rb', line 9 def to_ruby tokens = Lexer.new(@template).lex nodes = Parser.parse(tokens) Compiler.new(nodes).to_ruby end |
#to_s(binding: TOPLEVEL_BINDING) ⇒ Object
15 16 17 |
# File 'lib/component_embedded_ruby/template.rb', line 15 def to_s(binding: TOPLEVEL_BINDING) eval(to_ruby, binding) # rubocop:disable Security/Eval end |