0
@@ -265,8 +265,8 @@ module Haml
0
- # haml_tag(name, attributes = {}) {...}
0
- # haml_tag(name, text, attributes = {}) {...}
0
+ # haml_tag(name, *flags, attributes = {}) {...}
0
+ # haml_tag(name, text, *flags, attributes = {}) {...}
0
# Creates an HTML tag with the given name and optionally text and attributes.
0
# Can take a block that will be executed
0
@@ -274,6 +274,11 @@ module Haml
0
# If the block is a Haml block or outputs text using puts,
0
# the text will be properly indented.
0
+ # <tt>flags</tt> is a list of symbol flags
0
+ # like those that can be put at the end of a Haml tag
0
+ # (<tt>:/</tt>, <tt>:<</tt>, and <tt>:></tt>).
0
+ # Currently, only <tt>:/</tt> and <tt>:<</tt> are supported.
0
@@ -304,23 +309,25 @@ module Haml
0
- def haml_tag(name,
attributes = {}, alt_atts = {}, &block)
0
+ def haml_tag(name,
*rest, &block)
0
- if attributes.is_a? String
0
- attributes = Haml::Precompiler.build_attributes(
0
- haml_buffer.html?, haml_buffer.options[:attr_wrapper], attributes)
0
- if text.nil? && block.nil? && haml_buffer.options[:autoclose].include?(name)
0
+ text = rest.shift if rest.first.is_a? String
0
+ flags << rest.shift while rest.first.is_a? Symbol
0
+ attributes = Haml::Precompiler.build_attributes(haml_buffer.html?,
0
+ haml_buffer.options[:attr_wrapper],
0
+ if text.nil? && block.nil? && (haml_buffer.options[:autoclose].include?(name) || flags.include?(:/))
0
puts "<#{name}#{attributes} />"
0
+ raise Error.new("Self-closing tags can't have content.") if text
0
+ raise Error.new("Illegal nesting: nesting within a self-closing tag is illegal.") if block
0
tag = "<#{name}#{attributes}>"
0
tag << text.to_s << "</#{name}>"
0
@@ -332,6 +339,12 @@ module Haml
0
raise Error.new("Illegal nesting: content can't be both given to haml_tag :#{name} and nested within it.")
0
+ tag << capture_haml(&block).strip << "</#{name}>"
Comments
Great! :)
Waiting for a solution for the :> flag.
Thanks ;)
Unfortunately, I can’t imagine how :> would be possible, at least without some serious modifications to Buffer that I’m not sure are worth it.