Malt  Malt::Format::AbstractTemplate

[Validate]
Generated with RDazzle Newfish 1.4.0

AbstractTemplate

An AbstractTemplate is a subclass of Abstract. It is used as the base class for general purpose template formats which can be used to render any other type of format.

Public Instance Methods

method_missing(sym, *args, &yld) click to toggle source

ERB templates can be any type.

    # File lib/malt/formats/abstract_template.rb, line 30
30:     def method_missing(sym, *args, &yld)
31:       if Malt::Format.registry.key?(sym)  # TODO: Malt.machine.format?
32:         return render(sym, *args, &yld).to_s
33:       elsif md = /^to_/.match(sym.to_s)
34:         type = md.post_match.to_sym
35:         if Malt::Format.registry.key?(type)  # TODO: Malt.machine.format?
36:           return to(type, *args, &yld)
37:         end
38:       end
39:       super(sym, *args, &yld)
40:     end
render(*type_and_data, &yld) click to toggle source
    # File lib/malt/formats/abstract_template.rb, line 21
21:     def render(*type_and_data, &yld)
22:       type, data = parse_type_and_data(type_and_data)
23:       opts = options.merge(:format=>type, :text=>text, :file=>file, :data=>data)
24:       render_engine.render(opts, &yld)
25:       #opts = options.merge(:format=>type, :text=>text, :file=>file, :data=>data, :engine=>engine)
26:       #Malt.render(opts, &yld)
27:     end
to(type, data=nil, &yld) click to toggle source
    # File lib/malt/formats/abstract_template.rb, line 12
12:     def to(type, data=nil, &yld)
13:       new_class   = Malt::Format.registry[type.to_sym]  # TODO: Malt.machine.format?
14:       new_text    = render(type, data, &yld)
15:       new_file    = refile(type)
16:       new_options = options.merge(:text=>new_text, :file=>new_file, :type=>type)
17:       new_class.new(new_options)
18:     end

Disabled; run with --debug to generate this.