Class: Rake::Pipeline::Web::Filters::LessFilter
- Inherits:
-
Filter
- Object
- Filter
- Rake::Pipeline::Web::Filters::LessFilter
- Includes:
- FilterWithDependencies
- Defined in:
- lib/rake-pipeline-web-filters/less_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.
Requires less-js
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
A hash of options to pass to Less when compiling.
Instance Method Summary collapse
- #external_dependencies ⇒ Object
-
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API.
-
#initialize(options = {}, context = nil, &block) ⇒ LessFilter
constructor
A new instance of LessFilter.
Constructor Details
#initialize(options = {}, context = nil, &block) ⇒ LessFilter
Returns a new instance of LessFilter.
29 30 31 32 33 |
# File 'lib/rake-pipeline-web-filters/less_filter.rb', line 29 def initialize(={}, context = nil, &block) block ||= proc { |input| input.sub(/\.less$/, '.css') } super(&block) @options = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns a hash of options to pass to Less when compiling.
25 26 27 |
# File 'lib/rake-pipeline-web-filters/less_filter.rb', line 25 def @options end |
Instance Method Details
#external_dependencies ⇒ Object
51 52 53 |
# File 'lib/rake-pipeline-web-filters/less_filter.rb', line 51 def external_dependencies [ 'less' ] end |
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API. Attempts to compile each input file with LessJs.
44 45 46 47 48 49 |
# File 'lib/rake-pipeline-web-filters/less_filter.rb', line 44 def generate_output(inputs, output) parser = Less::Parser.new inputs.each do |input| output.write parser.parse(input.read).to_css end end |