I'm looking for cleaner solution, more Slim like, to write tag inside tag, this is what I have so far:
td = "#{p.created_at.to_formatted_s(:long)} <small>(#{time_ago_in_words(p.created_at)} ago)</small>".html_safe
Code above works fine - generate output I want, but doesn't look clean for me. I've tried rewrite it to eRuby
<td><%= p.created_at.to_formatted_s(:long) %> <small><%= time_ago_in_words(p.created_at) %> ago)</small></td>
And then convert it to Slim using Erb2Slim converter
td
= p.created_at.to_formatted_s(:long)
small
= time_ago_in_words(p.created_at)
| ago)
After that it doesn't show small
tag and its content, any idea how and what is the best way to write above code in Slim?
Seems like you have a problem with indents (spaces). Try to use the following indents:
td
= p.created_at.to_formatted_s(:long)
|
small
| (
= time_ago_in_words(p.created_at)
| ago)
Note: in 3rd line 2 spaces needed after the pipe