Skip to content

Produces broken syntax for certain calls inside attribute interpolation #921

Description

@elia

Here's the reproduction

puts Haml::Engine.new(%{%a(data-foo="#{render 'foobar',foo: bar}")}).precompiled.gsub(';', "\n")

the following has been re-indented for readability, notice that the second line produces invalid code ("#{render 'foobar')

_hamlout.buffer << ("<a".freeze)
_haml_attribute_compiler1 = ("#{render 'foobar')
case (_haml_attribute_compiler1)
when Hash
  _hamlout.buffer << ((_hamlout.attributes({ "data-foo".freeze => _haml_attribute_compiler1 }, nil)).to_s)

when true
  _hamlout.buffer << (" data-foo".freeze)

when false, nil
else
  _hamlout.buffer << (" data-foo='".freeze)

  _hamlout.buffer << (::Haml::Helpers.html_escape((_haml_attribute_compiler1)))

  _hamlout.buffer << ("'".freeze)

end
_haml_attribute_compiler2 = (bar}")
case (_haml_attribute_compiler2)
when Hash
  _hamlout.buffer << ((_hamlout.attributes({ "foo".freeze => _haml_attribute_compiler2 }, nil)).to_s)
  
when true
  _hamlout.buffer << (" foo".freeze)
  
when false, nil
else
  _hamlout.buffer << (" foo='".freeze)
  
  _hamlout.buffer << (::Haml::Helpers.html_escape((_haml_attribute_compiler2)))
  
  _hamlout.buffer << ("'".freeze)
  
end
_hamlout.buffer << ("></a>\n".freeze)

Activity

  1. k0kubun commented on May 3, 2017

    @k0kubun
    Member

    Thank you for reporting. But this is essentially the same as #917 and already fixed on master branch. Please wait for new release.

  2. k0kubun commented on May 3, 2017

    @k0kubun
    Member

    @amatsuda Could you ship a new release?

  3. amatsuda commented on May 3, 2017

    @amatsuda
    Member

    Yes, just released 5.0.1 gem including the patch for this issue.

  4. added a commit that references this issue on Jun 21, 2017
  5. added a commit that references this issue on Jun 21, 2017
  6. added a commit that references this issue on May 11, 2026
  7. added a commit that references this issue on May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions