Class: Malt::Format::Erb

Inherits:
AbstractTemplate show all
Defined in:
lib/malt/formats/erb.rb

Instance Attribute Summary

Attributes inherited from Abstract

#options

Instance Method Summary collapse

Methods inherited from AbstractTemplate

#method_missing, #render, #to

Methods inherited from Abstract

#default, #engine, engine, extensions, #extensions, #file, file_extension, #file_read, #file_type, #parse_type_from_data, #refile, register, #render, #render_into, #rendering_parameters, #scope_vs_data, #subtype, #text, #to, #to_default, #to_s, #type, #with, #with!

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Malt::Format::AbstractTemplate

Instance Method Details

#html(*data, &content) ⇒ 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.



17
18
19
# File 'lib/malt/formats/erb.rb', line 17

def html(*data, &content)
  render_into(:html, *data, &content)
end

#to_html(*data, &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.



24
25
26
27
28
29
# File 'lib/malt/formats/erb.rb', line 24

def to_html(*data, &yld)
  new_text    = render(:html, *data, &yld)
  new_file    = refile(:html)
  new_options = options.merge(:text=>new_text, :file=>new_file, :type=>:html)
  HTML.new(new_options)
end