Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8910013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:34:51+00:00 2026-06-15T03:34:51+00:00

Here is my Haml: %a{:href => /settings, data-icon => &#9881;} Which outputs: <a data-icon=’&amp;#9881;’

  • 0

Here is my Haml:

%a{:href => "/settings", "data-icon" => "&#9881;"}

Which outputs:

<a data-icon='&amp;#9881;' href='/settings'>Settings</a>

I want to output:

<a data-icon='&#9881;' href='/settings'>Settings</a>

So I’ve tried escaping the ampersand:

%a{:href => "/settings", "data-icon" => "\&#9881;"}

But it seems escapes only work for the first character of a line.

I’ve also tried different methods of interpolation/escaping with no success:

"#{"&#9881;"}"

Using plain html (<a href="/settings" data-icon="&#9881">Settings</a>) is a stopgap measure that I do not consider a solution. What if I want to set the data-icon programatically?

Another option is:

%a{:href => "#", "data-icon" => "⚙"} Settings

But what if I want to use PUA characters? It also makes it a lot harder to tell what the character is in the markup.

Demo

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:34:53+00:00Added an answer on June 15, 2026 at 3:34 am

    You need to set the escape_attrs option to false or :once.

    $ haml --no-escape-attrs
    %a{:href => "/settings", "data-icon" => "&#9881;"}
    

    output:

    <a data-icon='&#9881;' href='/settings'></a>
    

    --no-escape-attrs sets the escape_attrs option to false from the command line. See the docs for info on how to set options in other cases.

    (It doesn’t look like codepen.io lets you specify Haml options, so I can’t provide a demo there).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using f.semantic_fields_for with haml here is the current snippet. %ul.documents =f.semantic_fields_for :documents do
Here is fragments of my HAML view: %script{:type => text/javascript, :src => assets/application.js} :javascript
I have a Ruby application, and here is my setup: I have this HAML
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
In HAML I often want to use a tag with punctuation following immediately after
I have a HAML template that I want to render and optionally provide a
I am working on a project using sinatra with haml for templates. I want
I want to have a rake task that reads a HAML file and creates
I'm having troubles with rendering response via AJAX. Here is how my .js.haml view
I don't understand what's happening here. I want to put a button_to in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.