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
Constant Summary collapse
- VERSION =
Gem::Version.new("0.2.0")
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, io: StringIO.new) ⇒ Template
constructor
A new instance of Template.
- #render(context = "") ⇒ Object
Constructor Details
Class Method Details
.render(input, context = "", io: StringIO.new) ⇒ Object
10 11 12 |
# File 'lib/template.rb', line 10 def self.render(input, context = "", io: StringIO.new) new(input, io: io).render(context) end |
Instance Method Details
#render(context = "") ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/template.rb', line 14 def render(context = "") if context.present? context = ::Code.evaluate(context) else context = ::Code::Object::Dictionnary.new end ::Template::Node::Template.new(@parsed).evaluate(context: context, io: @io) @io.is_a?(StringIO) ? @io.string : nil end |