Trip
Trip

Reputation: 27114

Rails helpers return just strings. How would I have it return HTML?

I am trying to return this in it's predictable HTML way :

'Page Total ' + @total_on_page + tag('br') + 'Total All Pages'.html_safe + @total

But instead it just parses the br/ as plain text. How do I return a working HTML version of br/ ?

Expected Output :

Page Total $123123
Total All Pages $12312312   

Actual Output :

Page Total $8,296.42<br />Total All Pages$23,669.73

Upvotes: 4

Views: 2797

Answers (1)

Veraticus
Veraticus

Reputation: 16064

The .html_safe at the end is applying only to the last string, not the overall string. You want something more like this:

('Page Total ' + @total_on_page + tag('br') + 'Total All Pages' + @total).html_safe

Upvotes: 10

Related Questions