9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/hamlbars/ext/compiler.rb', line 9
def self.included(base)
base.instance_eval do
if Haml::VERSION >= "3.2"
def build_attributes_with_handlebars_attributes (is_html, attr_wrapper, escape_attrs, hyphenate_data_attrs, attributes={})
handlebars_rendered_attributes = build_attributes_with_handlebars_attributes_base(is_html, attr_wrapper, escape_attrs, attributes)
(handlebars_rendered_attributes * '') +
build_attributes_without_handlebars_attributes(is_html, attr_wrapper, escape_attrs, hyphenate_data_attrs, attributes)
end
else
def build_attributes_with_handlebars_attributes (is_html, attr_wrapper, escape_attrs, attributes={})
handlebars_rendered_attributes = build_attributes_with_handlebars_attributes_base(is_html, attr_wrapper, escape_attrs, attributes)
(handlebars_rendered_attributes * '') +
build_attributes_without_handlebars_attributes(is_html, attr_wrapper, escape_attrs, attributes)
end
end
def build_attributes_with_handlebars_attributes_base(is_html, attr_wrapper, escape_attrs, attributes={})
handlebars_rendered_attributes = []
if bind = attributes.delete('bind')
handlebars_rendered_attributes << Hamlbars::Ext::Compiler.handlebars_attributes('bind-attr', bind)
end
if hb = attributes.delete('hb')
(hb.respond_to?(:each) ? hb : [hb]).each do |expression|
handlebars_rendered_attributes << " {{#{expression}}}"
end
end
if action = attributes.delete('_action')
actionName, rest = action.split(/\s/, 2)
handlebars_rendered_attributes << " {{action \"#{actionName}\" #{rest}}}"
end
handlebars_rendered_attributes
end
alias build_attributes_without_handlebars_attributes build_attributes
alias build_attributes build_attributes_with_handlebars_attributes
end
end
|