Class: Tilt::Mapping
- Inherits:
-
Object
- Object
- Tilt::Mapping
- Defined in:
- lib/tilt/pipeline.rb
Instance Method Summary collapse
-
#pipeline(ext, options = {}) ⇒ Object
Register a new template class using the given extension that represents a pipeline of multiple existing template, where the output from the previous template is used as input to the next template.
Instance Method Details
#pipeline(ext, options = {}) ⇒ Object
Register a new template class using the given extension that represents a pipeline of multiple existing template, where the output from the previous template is used as input to the next template. For example, if you just call this with a single extension string:
mapping.pipeline('scss.erb')
This will register a template class that processes the input with the erb
template processor, and takes the output of that and feeds it to the scss
template processor, returning the output of the scss
template processor as the result of the pipeline.
Options:
- :templates
-
specify the templates to call in the given order, instead of determining them from the extension (e.g.
['erb', 'scss']
) - :extra_exts
-
Any additional extensions you want to register for the created class (e.g.
'scsserb'
) - String
-
Any string option that matches one of the templates being used in the pipeline is considered options for that template (e.g.
'erb'=>{:outvar=>'@foo'}, 'scss'=>{:style=>:compressed}
)
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tilt/pipeline.rb', line 34 def pipeline(ext, ={}) templates = [:templates] || ext.split('.').reverse templates = templates.map{|t| [self[t], [t] || {}]} klass = Class.new(Pipeline) klass.send(:const_set, :TEMPLATES, templates) register(klass, ext, *Array([:extra_exts])) klass end |