HAML 6: Replacement or alternative for haml_tag?

491 Views Asked by At

In upgrading an older Rails app to the latest and greatest versions of everything, I've discovered that the haml_tag helper method was removed from Haml::Helpers in version 6. A quick grep of the haml and haml-rails sources reveal that there are no references to it (other than the changelog noting its removal).

haml_tag lets you generate output with an arbitrary tag name, attributes, and content, like this:

- tag_name = my_content_model.tag_name || "section"  # something dynamic
- haml_tag(tag_name, {attr: value, attr2: value2}) do
    %div.inner
        %h2 Contents go here.

I make heavy use of haml_tag in a CMS where users can pick a tag name for their blocks of content, and would prefer not to have to redesign that feature. Is there an adequate replacement for it, perhaps in a third-party library?

(For now I have my Gemfile locking HAML to version 5)

1

There are 1 best solutions below

0
Richard On

It seems like the answer here is to change calls from haml_tag to content_tag when using haml v6.