mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Allow generator to use options
This commit is contained in:
parent
ea0ec1d97c
commit
148e51d922
2 changed files with 20 additions and 1 deletions
|
@ -18,7 +18,10 @@ module Hamlit
|
|||
filter :MultiFlattener
|
||||
filter :StaticMerger
|
||||
use :Generator do
|
||||
options[:generator].new
|
||||
valid_options = options.to_hash.select do |key, value|
|
||||
options[:generator].options.valid_key?(key)
|
||||
end
|
||||
options[:generator].new(valid_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
16
spec/hamlit/engine_spec.rb
Normal file
16
spec/hamlit/engine_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
describe Hamlit::Engine do
|
||||
describe '.new' do
|
||||
subject { described_class.new(options) }
|
||||
|
||||
let(:buffer) { '_a' }
|
||||
let(:options) do
|
||||
{ buffer: buffer, generator: Temple::Generators::ArrayBuffer }
|
||||
end
|
||||
|
||||
it 'allows generator valid options' do
|
||||
expect(subject.call('')).to eq(
|
||||
"#{buffer} = []; ; #{buffer} = #{buffer}.join",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue