Class: ComponentEmbeddedRuby::Template
- Inherits:
-
Object
- Object
- ComponentEmbeddedRuby::Template
- Defined in:
- lib/component_embedded_ruby/template.rb
Instance Method Summary collapse
-
#initialize(template, safe_append_method: "<<", unsafe_append_method: "<<", output_var_name: "__crb_out") ⇒ Template
constructor
A new instance of Template.
- #to_ruby ⇒ Object
- #to_s(binding: TOPLEVEL_BINDING) ⇒ Object
Constructor Details
#initialize(template, safe_append_method: "<<", unsafe_append_method: "<<", output_var_name: "__crb_out") ⇒ Template
Returns a new instance of Template.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/component_embedded_ruby/template.rb', line 5 def initialize( template, safe_append_method: "<<", unsafe_append_method: "<<", output_var_name: "__crb_out" ) @template = template @safe_append_method = safe_append_method @unsafe_append_method = unsafe_append_method @output_var_name = output_var_name end |
Instance Method Details
#to_ruby ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/component_embedded_ruby/template.rb', line 17 def to_ruby tokens = Lexer.new(@template).lex nodes = Parser.parse(tokens) Compiler.new( nodes, safe_append_method: @safe_append_method, unsafe_append_method: @unsafe_append_method, output_var_name: @output_var_name ).to_ruby end |
#to_s(binding: TOPLEVEL_BINDING) ⇒ Object
28 29 30 |
# File 'lib/component_embedded_ruby/template.rb', line 28 def to_s(binding: TOPLEVEL_BINDING) eval(to_ruby, binding) # rubocop:disable Security/Eval end |