Class: Natsuzora::Template
- Inherits:
-
Object
- Object
- Natsuzora::Template
- Defined in:
- lib/natsuzora/template.rb
Overview
Top-level entry that compiles a template source and renders against a Payload.
‘Template#render` accepts only a Payload, which is the explicit boundary between untrusted host data and the internal value space. Callers wishing to render from a raw Hash should either use the convenience facade render or wrap the Hash in `Natsuzora::Payload.new(…)` themselves.
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
Instance Method Summary collapse
-
#initialize(source, include_root: nil) ⇒ Template
constructor
A new instance of Template.
-
#render(payload) ⇒ String
Rendered output.
Constructor Details
#initialize(source, include_root: nil) ⇒ Template
Returns a new instance of Template.
15 16 17 18 19 |
# File 'lib/natsuzora/template.rb', line 15 def initialize(source, include_root: nil) @source = source @loader = include_root && TemplateLoader.new(include_root) @ast = parse_ruby(source) end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
13 14 15 |
# File 'lib/natsuzora/template.rb', line 13 def ast @ast end |