59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/shady.rb', line 59
def on_html_tag(name, attrs, content = nil)
return super unless @pretty
name = name.to_s
closed = !content || (empty_exp?(content) && options[:autoclose].include?(name))
@pretty = false
result = [:multi, [:static, "#{tag_indent(name)}<#{name}"], compile(attrs)]
result << [:static, (closed && @format != :html ? ' /' : '') + '>']
@pretty = true
case content
in [:multi, [:newline]]
return (result << [:static, "</#{name}>"])
in [:multi, [:multi, [:static, str]]]
return (result << [:static, "#{str.strip}</#{name}>"])
in [:multi, [:escape, true, [:dynamic, code]], [:multi, [:newline]]]
return (result << [:multi, [:escape, true, [:dynamic, code]], [:static, "</#{name}>"]])
else nil
end if options[:strip]
@pretty = !@pre_tags || !options[:pre_tags].include?(name)
if content
@indent += 1
result << compile(content)
@indent -= 1
end
unless closed
indent = tag_indent(name)
result << [:static, "#{content && !empty_exp?(content) ? indent : ''}</#{name}>"]
end
@pretty = true
result
end
|