Class: Template
- Inherits:
-
Object
- Object
- Template
- Defined in:
- lib/template.rb,
lib/template/node.rb,
lib/template/parser.rb,
lib/template/node/part.rb,
lib/template/node/template.rb,
lib/template/node/code_part.rb,
lib/template/node/text_part.rb,
lib/template/parser/template.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input) ⇒ Template
constructor
A new instance of Template.
- #render(context = "") ⇒ Object
Constructor Details
Class Method Details
.render(input, context = "") ⇒ Object
7 8 9 |
# File 'lib/template.rb', line 7 def self.render(input, context = "") new(input).render(context) end |
Instance Method Details
#render(context = "") ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/template.rb', line 11 def render(context = "") if context.present? context = ::Code.evaluate(context) else context = ::Code::Object::Dictionnary.new end ::Template::Node::Template.new(@parsed).evaluate(context).map(&:to_s).join end |