mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fix syntax error in data attribute hash
Fixes #17.
This was a regression of 7d3056b89a
.
This commit is contained in:
parent
2e871b7ba6
commit
7e6b732ae7
3 changed files with 13 additions and 4 deletions
|
@ -10,16 +10,16 @@ module Hamlit
|
|||
class Attribute
|
||||
include Concerns::AttributeBuilder
|
||||
|
||||
def self.build(quote, attributes, base = {})
|
||||
def self.build(quote, base, attributes = {})
|
||||
builder = self.new(quote)
|
||||
builder.build(attributes, base)
|
||||
builder.build(base, attributes)
|
||||
end
|
||||
|
||||
def initialize(quote)
|
||||
@quote = quote
|
||||
end
|
||||
|
||||
def build(attributes, base)
|
||||
def build(base, attributes)
|
||||
result = ''
|
||||
merge_attributes(base, attributes).each do |key, value|
|
||||
if value == true
|
||||
|
|
|
@ -30,7 +30,7 @@ module Hamlit
|
|||
def compile_runtime_attribute(str, base = nil)
|
||||
str = str.gsub(/(\A\{|\}\Z)/, '')
|
||||
quote = options[:attr_quote].inspect
|
||||
code = "::Hamlit::Attribute.build(#{[quote, str, base].compact.join(', ')})"
|
||||
code = "::Hamlit::Attribute.build(#{[quote, base, str].compact.join(', ')})"
|
||||
[:dynamic, code]
|
||||
end
|
||||
|
||||
|
|
|
@ -125,6 +125,15 @@ describe Hamlit::Engine do
|
|||
end
|
||||
|
||||
describe 'nested attributes' do
|
||||
it 'renders data attribute by hash' do
|
||||
assert_render(<<-'HAML', <<-HTML)
|
||||
- hash = { bar: 'baz' }
|
||||
%span.foo{ data: hash }
|
||||
HAML
|
||||
<span class='foo' data-bar='baz'></span>
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'renders true attributes' do
|
||||
assert_render(<<-'HAML', <<-HTML)
|
||||
%span{ data: { disable: true } } bar
|
||||
|
|
Loading…
Add table
Reference in a new issue