class Haml::Parser
def tag(line)
def tag(line) tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace, nuke_inner_whitespace, action, value, last_line = parse_tag(line.text) preserve_tag = @options.preserve.include?(tag_name) nuke_inner_whitespace ||= preserve_tag escape_html = (action == '&' || (action != '!' && @options.escape_html)) case action when '/'; self_closing = true when '~'; parse = preserve_script = true when '=' parse = true if value[0] == ?= value = Util.unescape_interpolation(value[1..-1].strip) escape_interpolation = true if escape_html escape_html = false end when '&', '!' if value[0] == ?= || value[0] == ?~ parse = true preserve_script = (value[0] == ?~) if value[1] == ?= value = Util.unescape_interpolation(value[2..-1].strip) escape_interpolation = true if escape_html escape_html = false else value = value[1..-1].strip end elsif Util.contains_interpolation?(value) value = Util.unescape_interpolation(value) escape_interpolation = true if escape_html parse = true escape_html = false end else if Util.contains_interpolation?(value) value = Util.unescape_interpolation(value, escape_html) parse = true escape_html = false end end attributes = Parser.parse_class_and_id(attributes) dynamic_attributes = DynamicAttributes.new if attributes_hashes[:new] static_attributes, attributes_hash = attributes_hashes[:new] AttributeMerger.merge_attributes!(attributes, static_attributes) if static_attributes dynamic_attributes.new = attributes_hash end if attributes_hashes[:old] static_attributes = parse_static_hash(attributes_hashes[:old]) AttributeMerger.merge_attributes!(attributes, static_attributes) if static_attributes dynamic_attributes.old = attributes_hashes[:old] unless static_attributes || @options.suppress_eval end raise SyntaxError.new(Error.message(:illegal_nesting_self_closing), @next_line.index) if block_opened? && self_closing raise SyntaxError.new(Error.message(:no_ruby_code, action), last_line - 1) if parse && value.empty? raise SyntaxError.new(Error.message(:self_closing_content), last_line - 1) if self_closing && !value.empty? if block_opened? && !value.empty? && !is_ruby_multiline?(value) raise SyntaxError.new(Error.message(:illegal_nesting_line, tag_name), @next_line.index) end self_closing ||= !!(!block_opened? && value.empty? && @options.autoclose.any? {|t| t === tag_name}) value = nil if value.empty? && (block_opened? || self_closing) line.text = value line = handle_ruby_multiline(line) if parse ParseNode.new(:tag, line.index + 1, :name => tag_name, :attributes => attributes, :dynamic_attributes => dynamic_attributes, :self_closing => self_closing, :nuke_inner_whitespace => nuke_inner_whitespace, :nuke_outer_whitespace => nuke_outer_whitespace, :object_ref => object_ref, :escape_html => escape_html, :preserve_tag => preserve_tag, :preserve_script => preserve_script, :parse => parse, :value => line.text, :escape_interpolation => escape_interpolation) end