Class: Malt::Format::Erb
- Inherits:
-
AbstractTemplate
- Object
- Abstract
- AbstractTemplate
- Malt::Format::Erb
- Defined in:
- lib/malt/formats/erb.rb
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#html(data = nil, &yld) ⇒ Object
Technically #method_missing will pick this up, but since it is likely to be the most commonly used, adding the method directly will provide a small speed boost.
-
#rb ⇒ Object
TODO: Lookup engine from engine registry.
-
#to_html(data = nil, &yld) ⇒ Object
Technically #method_missing will pick this up, but since it is likely to be the most commonly used, adding the method directly will provide a small speed boost.
-
#to_rb ⇒ Object
(also: #to_ruby, #precompile)
Erb templates can be “pre-compiled” into Ruby templates.
Methods inherited from AbstractTemplate
Methods inherited from Abstract
#default, #engine, engine, extensions, #extensions, #file, #parse_type_and_data, #refile, register, #render, #subtype, #text, #to, #to_default, #to_s, #type
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Malt::Format::AbstractTemplate
Instance Method Details
#html(data = nil, &yld) ⇒ Object
Technically #method_missing will pick this up, but since it is likely to be the most commonly used, adding the method directly will provide a small speed boost.
33 34 35 |
# File 'lib/malt/formats/erb.rb', line 33 def html(data=nil, &yld) render(:html, data, &yld) end |
#rb ⇒ Object
TODO: Lookup engine from engine registry.
14 15 16 |
# File 'lib/malt/formats/erb.rb', line 14 def rb(*) render_engine.compile(:text=>text, :file=>file) end |
#to_html(data = nil, &yld) ⇒ Object
Technically #method_missing will pick this up, but since it is likely to be the most commonly used, adding the method directly will provide a small speed boost.
40 41 42 43 44 45 |
# File 'lib/malt/formats/erb.rb', line 40 def to_html(data=nil, &yld) new_text = render(:html, data, &yld) new_file = refile(:html) = .merge(:text=>new_text, :file=>new_file, :type=>:html) HTML.new() end |
#to_rb ⇒ Object Also known as: to_ruby, precompile
Erb templates can be “pre-compiled” into Ruby templates.
19 20 21 22 |
# File 'lib/malt/formats/erb.rb', line 19 def to_rb(*) text = rb Ruby.new(:text=>text, :file=>refile(:rb)) end |