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
Abstract
Abstract format class serves as the base class for all other format classes.
Public Class Methods
# File lib/malt/formats/abstract.rb, line 51
51: def self.engine(set=nil)
52: @engine = set if set
53: @engine
54: end
# File lib/malt/formats/abstract.rb, line 44
44: def self.extensions
45: @extensions
46: end
# File lib/malt/formats/abstract.rb, line 59
59: def initialize(options={})
60: @options = options.rekey
61: @type = @options[:type]
62: initialize_engine
63: end
Register the class to an extension type.
# File lib/malt/formats/abstract.rb, line 30
30: def self.register(*exts)
31: @extensions = exts
32: Malt::Format.register(self, *exts)
33:
34: #exts.each do |ext|
35: # Abstract.module_eval %{
36: # def to_#{ext}(*db,&yld)
37: # convert(:#{ext},*db,&yld)
38: # end
39: # }
40: #end
41: end
Public Instance Methods
Default rendering type is :html. Override if it differs for the subclassing format.
# File lib/malt/formats/abstract.rb, line 188
188: def default
189: :html
190: end
Specified engine to use for rendering.
Keep in mind that the ability to specify the engine varies based on engine, format and output format.
# File lib/malt/formats/abstract.rb, line 93
93: def engine
94: options[:engine] || self.class.engine
95: end
# File lib/malt/formats/abstract.rb, line 167
167: def extensions
168: self.class.extensions
169: end
File name of document.
# File lib/malt/formats/abstract.rb, line 80
80: def file
81: @file ||= options[:file].to_s
82: end
# File lib/malt/formats/abstract.rb, line 193
193: def parse_type_and_data(type_and_data)
194: if Symbol === type_and_data.first
195: type = type_and_data.first
196: data = type_and_data.last
197: else
198: type = nil
199: data = type_and_data.first
200: end
201: return type, data
202: end
Produce a new filename replacing old extension with new extension.
type - Symbol representation of extension (e.g. :html).
Returns a String of the new file name.
# File lib/malt/formats/abstract.rb, line 150
150: def refile(type=nil)
151: if file
152: if type
153: type = type.to_s.sub(/^\./,'')
154: fext = self.class.extensions.find{|e| file.end_with?(e)}
155: new_file = file.chomp(fext) + type
156: else
157: fext = self.class.extensions.find{|e| file.end_with?(e)}
158: new_file = file.chomp('.'+fext)
159: end
160: else
161: new_file = nil
162: end
163: new_file
164: end
Render to default or given format.
If the first argument is a Symbol it is considered the format, otherwise it is taken to be the database for rendering template variables.
# File lib/malt/formats/abstract.rb, line 106
106: def render(*type_and_data, &yld)
107: type, data = parse_type_and_data(type_and_data)
108: meth = method(type || default)
109: #__send__(type || default, data, &yld)
110: meth.arity == 0 ? meth.call(&yld) : meth.call(data, &yld)
111: end
# File lib/malt/formats/abstract.rb, line 172
172: def subtype
173: File.extname(file.chomp(type))
174: end
Document source text.
# File lib/malt/formats/abstract.rb, line 75
75: def text
76: @text ||= options[:text] || File.read(file)
77: end
# File lib/malt/formats/abstract.rb, line 98
98: def to(type, data=nil, &yld)
99: __send__("to_#{type}", data, &yld)
100: end
# File lib/malt/formats/abstract.rb, line 182
182: def to_default(data=nil, &yld)
183: to(default, data, &yld)
184: end
Disabled; run with --debug to generate this.