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 886543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:05:10+00:00 2026-05-15T13:05:10+00:00

In haml, how do I render the following incredibly basic HTML: <p>Results found for

  • 0

In haml, how do I render the following incredibly basic HTML:

<p>Results found for <strong>search term</strong>

where ‘search term’ is actually a Ruby variable called @query?

I’m trying the following,

%p results found for <strong>= @query</strong>

But that renders = @query literally. If I try:

%p results found for <strong>
= @query
</strong>

then the query term renders correctly, but is on a new line.

Also, I’m wondering if there’s a better way to render <strong> in haml, while keeping everything on the same line.

I’m aware of the haml documentation, but as far as I can see there isn’t an example of using a simple inline Ruby variable.

—–UPDATE——-

The following code works, and shows how to use a variable that’s not within tags:

   %p   
    = @trials_found_count
    results found for
    %strong= @query

But I find it really unreadable – it’s hard to tell that it renders as just one line of HTML without adding a comment above.

Is there a way I can put all this code on a single line? Or is this just how haml works?

  • 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-05-15T13:05:11+00:00Added an answer on May 15, 2026 at 1:05 pm

    HAML is whitespace delimited. Nested tags go on the line below and one level in from the tag above. Embedded Ruby from which you want to display output is opened with an ‘=’. Embedded Ruby which you don’t want to display such as the start of loops uses ‘-‘ These are equivalent to <%= %> and <% %> respectively in erb.

    What you want would look like this:

    %p 
       results found for
       %strong= @query
    

    Which would produce the html:

    <p>results found for <strong>@query</strong></p>
    

    It should be noted that the ‘=’ to start Ruby evaluation can only come at the beginning of the line or after a tag declaration and that only one tag declaration can occur per line.
    The Ruby Evaluation section of the reference you linked covers embedded Ruby in detail and the haml tutorial which covers embedded ruby and many other haml basics is here:
    http://haml-lang.com/tutorial.html

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

Sidebar

Ask A Question

Stats

  • Questions 469k
  • Answers 470k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Select Case True Case RadioButton1.Checked Case RadioButton2.Checked Case RadioButton3.Checked Case… May 16, 2026 at 2:51 am
  • Editorial Team
    Editorial Team added an answer I have fixed it myself. Apparently, when accessing such objects… May 16, 2026 at 2:51 am
  • Editorial Team
    Editorial Team added an answer I think the solution will be database-specific. For example, for… May 16, 2026 at 2:51 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.