Class: Rake::Pipeline::Web::Filters::TiltFilter
- Inherits:
-
Filter
- Object
- Filter
- Rake::Pipeline::Web::Filters::TiltFilter
- Defined in:
- lib/rake-pipeline-web-filters/tilt_filter.rb
Overview
A filter that accepts a series of inputs and translates them using the Tilt template interface, which will attempt to guess which template language to use based on the input file extension.
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
A hash of options to pass to Tilt when rendering.
Instance Method Summary collapse
-
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API.
-
#initialize(options = {}, &block) ⇒ TiltFilter
constructor
A new instance of TiltFilter.
Constructor Details
#initialize(options = {}, &block) ⇒ TiltFilter
Returns a new instance of TiltFilter.
30 31 32 33 |
# File 'lib/rake-pipeline-web-filters/tilt_filter.rb', line 30 def initialize(={}, &block) super(&block) @options = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns a hash of options to pass to Tilt when rendering.
24 25 26 |
# File 'lib/rake-pipeline-web-filters/tilt_filter.rb', line 24 def @options end |
Instance Method Details
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API. Attempts to compile each input file with Tilt, passing the file through unchanged if Tilt can’t find a template class for the file.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rake-pipeline-web-filters/tilt_filter.rb', line 45 def generate_output(inputs, output) inputs.each do |input| out = if (template_class = Tilt[input.path]) template_class.new(nil, 1, ) { |t| input.read }.render else input.read end output.write out end end |