Class: Template
Defined Under Namespace
Classes: OutputBuffer
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, &body) ⇒ Template
constructor
A new instance of Template.
- #inspect ⇒ Object
- #render(ctx = self) ⇒ Object
Constructor Details
#initialize(name, &body) ⇒ Template
Returns a new instance of Template
17 18 19 20 |
# File 'opal/stdlib/template.rb', line 17 def initialize(name, &body) @name, @body = name, body Template[name] = self end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
15 16 17 |
# File 'opal/stdlib/template.rb', line 15 def body @body end |
Class Method Details
.[](name) ⇒ Object
[View source]
3 4 5 |
# File 'opal/stdlib/template.rb', line 3 def self.[](name) @_cache[name] || @_cache["templates/#{name}"] end |
.[]=(name, instance) ⇒ Object
[View source]
7 8 9 |
# File 'opal/stdlib/template.rb', line 7 def self.[]=(name, instance) @_cache[name] = instance end |
.paths ⇒ Object
[View source]
11 12 13 |
# File 'opal/stdlib/template.rb', line 11 def self.paths @_cache.keys end |
Instance Method Details
#inspect ⇒ Object
[View source]
22 23 24 |
# File 'opal/stdlib/template.rb', line 22 def inspect "#<Template: '#@name'>" end |
#render(ctx = self) ⇒ Object
[View source]
26 27 28 |
# File 'opal/stdlib/template.rb', line 26 def render(ctx = self) ctx.instance_exec(OutputBuffer.new, &@body) end |