Sha256: 185416f58c80c042f90554838e9ad63e8380cffd4a3fb2b6f2093a2b4ba4446a
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'malt/formats/abstract' module Malt module Format # 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. class AbstractTemplate < Abstract # def to(type, data=nil, &yld) new_class = Malt::Format.registry[type.to_sym] # TODO: Malt.machine.format? new_text = render(type, data, &yld) new_file = refile(type) new_options = options.merge(:text=>new_text, :file=>new_file, :type=>type) new_class.new(new_options) end # def render(*type_and_data, &yld) type, data = parse_type_and_data(type_and_data) opts = options.merge(:format=>type, :text=>text, :file=>file, :data=>data) render_engine.render(opts, &yld) #opts = options.merge(:format=>type, :text=>text, :file=>file, :data=>data, :engine=>engine) #Malt.render(opts, &yld) end # ERB templates can be any type. def method_missing(sym, *args, &yld) if Malt::Format.registry.key?(sym) # TODO: Malt.machine.format? return render(sym, *args, &yld).to_s elsif md = /^to_/.match(sym.to_s) type = md.post_match.to_sym if Malt::Format.registry.key?(type) # TODO: Malt.machine.format? return to(type, *args, &yld) end end super(sym, *args, &yld) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
malt-0.3.0 | lib/malt/formats/abstract_template.rb |