Class: Ytrbium::Engine
- Defined in:
- lib/ytrbium/engine.rb
Instance Method Summary collapse
- #expand(b = nil) ⇒ Object
-
#initialize(input, options = {}) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(input, options = {}) ⇒ Engine
Returns a new instance of Engine.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ytrbium/engine.rb', line 2 def initialize(input, = {}) @template_module = [:module] || Ytrbium.dsl stack_var = @defstack = "@_ybuf_stack" engine = self @template_module.module_eval do instance_variable_set(:@engine, engine) instance_variable_set(stack_var.to_sym, []) end bufvar = "@_ybuf" bufval = "Ytrbium::String.new" super(input, .merge(bufval: bufval, bufvar: bufvar, preamble: "options ||= {}; #{stack_var} = []; #{bufvar} = #{bufval};", escape: true, escapefunc: "@_ybuf.indent_expr", regexp: /<%(\|?={1,2}|!|-|\#|%|\|)?(.*?)([-=])?%>([ \t]*\r?\n)?/m)) end |
Instance Method Details
#expand(b = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ytrbium/engine.rb', line 20 def (b = nil) mod_src = src args = [] args.unshift @filename, 1 if @filename args.unshift b if b @template_module.module_eval do # rubocop:disable Security/Eval eval(mod_src, *args) # rubocop:enable Security/Eval end end |