Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 935
Trip Avatar asked Dec 28 '22 04:12

Trip


1 Answers

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
like image 89
Veraticus Avatar answered Jan 14 '23 03:01

Veraticus