In Files
Parent
- Object
Methods
Included Modules
Information
Class Index
![show/hide quicksearch [+]](../../assets/icon/find.png)
- Malt
- Malt::Engine
- Malt::Engine::Abstract
- Malt::Engine::BlueCloth
- Malt::Engine::Builder
- Malt::Engine::Erb
- Malt::Engine::Erector
- Malt::Engine::Erubis
- Malt::Engine::Haml
- Malt::Engine::Kramdown
- Malt::Engine::Less
- Malt::Engine::Liquid
- Malt::Engine::Markaby
- Malt::Engine::Mustache
- Malt::Engine::RDiscount
- Malt::Engine::RDoc
- Malt::Engine::Radius
- Malt::Engine::Radius::context;
- Malt::Engine::RagTag
- Malt::Engine::RedCloth
- Malt::Engine::Ruby
- Malt::Engine::Sass
- Malt::Engine::Tenjin
- Malt::Format
- Malt::Format::Abstract
- Malt::Format::AbstractTemplate
- Malt::Format::Builder
- Malt::Format::CSS
- Malt::Format::Erb
- Malt::Format::Erector
- Malt::Format::HTML
- Malt::Format::Haml
- Malt::Format::LESS
- Malt::Format::Latex
- Malt::Format::Liquid
- Malt::Format::Markaby
- Malt::Format::Markdown
- Malt::Format::Mustache
- Malt::Format::PDF
- Malt::Format::RBHTML
- Malt::Format::RDoc
- Malt::Format::RHTML
- Malt::Format::Radius
- Malt::Format::RagTag
- Malt::Format::Ruby
- Malt::Format::SCSS
- Malt::Format::Sass
- Malt::Format::Tenjin
- Malt::Format::Text
- Malt::Format::Textile
- Malt::Format::UnsupportedConversion
- Malt::Format::XML
- Malt::Format::YAML
- Malt::Kernel
- Malt::Machine
- Malt::Markup
- Malt::NoEngineError
- Malt::Template
- Hash
- OpenStruct
Public Class Methods
default(*exts)
click to toggle source
Register and set as the default for given extensions.
# File lib/malt/engines/abstract.rb, line 42
42: def self.default(*exts)
43: register(*exts)
44: exts.each do |ext|
45: Engine.defaults[ext.to_sym] = self
46: end
47: end
new(settings={})
click to toggle source
# File lib/malt/engines/abstract.rb, line 55
55: def initialize(settings={})
56: @settings = settings.rekey
57:
58: @cache = {}
59: @source = {}
60:
61: initialize_engine
62: end
Public Instance Methods
cache?()
click to toggle source
# File lib/malt/engines/abstract.rb, line 82
82: def cache?
83: !settings[:nocache]
84: end
Private Instance Methods
initialize_engine()
click to toggle source
Override this to load template engine library and prepare is for geeral usage.
# File lib/malt/engines/abstract.rb, line 90
90: def initialize_engine
91: end
make_binding(db, &yld)
click to toggle source
Convert a data source into a Binding. TODO: handle yld.
# File lib/malt/engines/abstract.rb, line 100
100: def make_binding(db, &yld)
101: return db if Binding === db # FIXME: no yld
102:
103: if db.respond_to?(:to_binding)
104: return db.to_binding(&yld)
105: end
106:
107: db = make_object(db, &yld)
108:
109: return db.instance_eval{ binding }
110: end
make_hash(db, &yld)
click to toggle source
Convert a data source into a Hash.
# File lib/malt/engines/abstract.rb, line 129
129: def make_hash(db, &yld)
130: if Binding === db
131: db = make_object(db)
132: end
133:
134: if db.respond_to?(:to_hash)
135: db = db.to_hash
136: db[:yield] = yld.call if yld
137: return db
138: end
139:
140: if db.respond_to?(:to_h)
141: db = db.to_h
142: db[:yield] = yld.call if yld
143: return db
144: end
145:
146: # last resort
147: db = db.instance_variables.inject({}) do |h, i|
148: k = i.sub('@','').to_sym
149: v = instance_variable_get(i)
150: h[k] = v
151: h
152: end
153: db[:yield] = yld.call if yld
154: return db
155: end
make_object(db, &yld)
click to toggle source
Convert a data source into an Object (aka a “scope”).
# File lib/malt/engines/abstract.rb, line 113
113: def make_object(db, &yld)
114: if db.respond_to?(:to_hash)
115: hash = db.to_hash
116: hash[:yield] = yld.call if yld
117: attrs = hash.keys.map{ |k| k.to_sym }
118: return Struct.new(*attrs).new(*hash.values)
119: end
120:
121: if Binding === db
122: eval('self', binding) # FIXME: no yld
123: end
124:
125: return db
126: end
Disabled; run with --debug to generate this.