Class: Malt::Engine::Abstract
- Includes:
- Kernel
- Defined in:
- lib/malt/engines/abstract.rb
Overview
Abstract Template class serves as the base class for all other Template classes.
Direct Known Subclasses
BlueCloth, Builder, Coffee, Creole, Erb, Erector, Erubis, Haml, Kramdown, Less, Liquid, Markaby, Maruku, Mustache, Nokogiri, RDiscount, RDoc, Radius, RagTag, RedCloth, Redcarpet, Ruby, Sass, String, Tenjin, WikiCloth
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Access to the options given to the initializer.
Class Method Summary collapse
-
.default(*exts) ⇒ Object
Register and set as the default for given extensions.
-
.register(*exts) ⇒ Object
Register the class to an extension type.
- .type ⇒ Object
Instance Method Summary collapse
- #cache? ⇒ Boolean
-
#create_engine(params = {}) ⇒ Object
Instantiate engine class with engine options and template text, if possible.
-
#initialize(settings = {}) ⇒ Abstract
constructor
A new instance of Abstract.
-
#prepare_engine(params = {}, &content) ⇒ Object
Prepare engine for rendering.
- #render(params, &block) ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Abstract
Returns a new instance of Abstract.
55 56 57 58 59 60 61 62 |
# File 'lib/malt/engines/abstract.rb', line 55 def initialize(settings={}) @settings = settings.rekey @cache = {} @source = {} require_engine end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Access to the options given to the initializer.
65 66 67 |
# File 'lib/malt/engines/abstract.rb', line 65 def settings @settings end |
Class Method Details
.default(*exts) ⇒ Object
Register and set as the default for given extensions.
42 43 44 45 46 47 |
# File 'lib/malt/engines/abstract.rb', line 42 def self.default(*exts) register(*exts) exts.each do |ext| Engine.defaults[ext.to_sym] = self end end |
.register(*exts) ⇒ Object
Register the class to an extension type.
37 38 39 |
# File 'lib/malt/engines/abstract.rb', line 37 def self.register(*exts) Engine.register(self, *exts) end |
.type ⇒ Object
50 51 52 |
# File 'lib/malt/engines/abstract.rb', line 50 def self.type basename.downcase.to_sym end |
Instance Method Details
#cache? ⇒ Boolean
68 69 70 |
# File 'lib/malt/engines/abstract.rb', line 68 def cache? !settings[:nocache] end |
#create_engine(params = {}) ⇒ Object
Instantiate engine class with engine options and template text, if possible.
The initialization MUST never include template data and should support caching, if feasible.
92 93 94 |
# File 'lib/malt/engines/abstract.rb', line 92 def create_engine(params={}) raise NotImplementedError, "not implemented" end |
#prepare_engine(params = {}, &content) ⇒ Object
Prepare engine for rendering.
82 83 84 |
# File 'lib/malt/engines/abstract.rb', line 82 def prepare_engine(params={}, &content) create_engine(params, &content) end |
#render(params, &block) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/malt/engines/abstract.rb', line 73 def render(params, &block) if into = params[:to] raise NotImplementedError, "unsupported rendering -- #{into}" else raise NotImplementedError, "unsupported rendering" end end |