Malt  Malt::Format::Ruby

[Validate]
Generated with RDazzle Newfish 1.4.0

Ruby

Yes, pure Ruby as a template format.

The ruby code is run through eval and whatever is returned is given as the rendering.

The Ruby format is a polyglot format —it accepts all conversion types and assumes the end-user knows it will be the result.

The Ruby type is also used for “precompiling” other formats such as ERB.

Public Instance Methods

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

Ruby templates can be any type.

    # File lib/malt/formats/ruby.rb, line 40
40:     def method_missing(sym, *args, &yld)
41:       if Malt::Format.registry.key?(sym)
42:         return to(sym, *args, &yld).to_s
43:       elsif md = /^to_/.match(sym.to_s)
44:         type = md.post_match.to_sym
45:         if Malt::Format.registry.key?(type)  # TODO: Malt.machine.format?
46:           return to(type, *args, &yld)
47:         end
48:       end
49:       super(sym, *args, &yld)
50:     end
rb(*) click to toggle source
    # File lib/malt/formats/ruby.rb, line 23
23:     def rb(*) ; text ; end
Also aliased as: ruby
render(*type_and_data, &yld) click to toggle source

def render_to(to, db, &yld)

  malt_engine.render(text, file, db, &yld)

end

    # File lib/malt/formats/ruby.rb, line 57
57:     def render(*type_and_data, &yld)
58:       type, data = parse_type_and_data(type_and_data)
59:       render_engine.render(:text=>text, :file=>file, :data=>data, &yld)
60:     end
ruby(*) click to toggle source
to(type, data=nil, &yld) click to toggle source
    # File lib/malt/formats/ruby.rb, line 31
31:     def to(type, data=nil, &yld)
32:       new_class   = Malt::Format.registry[type.to_sym]  # TODO: Malt.machine.format?
33:       new_text    = render(data, &yld)
34:       new_file    = refile(type)
35:       new_options = options.merge(:text=>new_text, :file=>new_file)
36:       new_class.new(new_options)
37:     end
to_rb(*) click to toggle source
    # File lib/malt/formats/ruby.rb, line 27
27:     def to_rb(*) ; self ; end
Also aliased as: to_ruby
to_ruby(*) click to toggle source

Private Instance Methods

render_engine() click to toggle source
    # File lib/malt/formats/ruby.rb, line 65
65:     def render_engine
66:       @render_engine ||= Malt::Engine::Ruby.new(options)
67:     end

Disabled; run with --debug to generate this.