diff --git a/lib/hamlit/attribute.rb b/lib/hamlit/attribute.rb
index 7518c376..5a6bfa46 100644
--- a/lib/hamlit/attribute.rb
+++ b/lib/hamlit/attribute.rb
@@ -10,18 +10,22 @@ module Hamlit
class Attribute
include Concerns::AttributeBuilder
- def self.build(quote, base, attributes = {})
+ def self.build(quote, *args)
builder = self.new(quote)
- builder.build(base, attributes)
+ builder.build(*args)
end
def initialize(quote)
@quote = quote
end
- def build(base, attributes)
+ def build(*args)
result = ''
- merge_attributes(base, attributes).each do |key, value|
+ attributes = args.inject({}) do |attributes, arg|
+ merge_attributes(attributes, arg)
+ end
+
+ attributes.each do |key, value|
if value == true
result += " #{key}"
next
diff --git a/spec/hamlit/engine/old_attributes_spec.rb b/spec/hamlit/engine/old_attributes_spec.rb
index 9801014a..0150008e 100644
--- a/spec/hamlit/engine/old_attributes_spec.rb
+++ b/spec/hamlit/engine/old_attributes_spec.rb
@@ -56,15 +56,6 @@ describe Hamlit::Engine do
HTML
end
- it 'renders runtime hash attribute' do
- assert_render(<<-'HAML', <<-HTML)
- - hash = { foo: 'bar' }
- %span{ hash }
- HAML
-
- HTML
- end
-
it 'renders multi-byte chars as static attribute value' do
assert_render(<<-'HAML', <<-HTML)
%img{ alt: 'こんにちは' }
@@ -73,6 +64,28 @@ describe Hamlit::Engine do
HTML
end
+ describe 'runtime attributes' do
+ it 'renders runtime hash attribute' do
+ assert_render(<<-'HAML', <<-HTML)
+ - hash = { foo: 'bar' }
+ %span{ hash }
+ HAML
+
+ HTML
+ end
+
+ it 'renders multiples hashes' do
+ assert_render(<<-'HAML', <<-HTML)
+ - h1 = { a: 'b' }
+ - h2 = { c: 'd' }
+ - h3 = { e: 'f' }
+ %span{ h1, h2, h3 }
+ HAML
+
+ HTML
+ end
+ end
+
describe 'joinable attributes' do
it 'joins class with a space' do
assert_render(<<-'HAML', <<-HTML)