I’m trying to render some text in Rails with simple_format, but I want to add a class to any lines shorter than 100 characters. Is this at all achievable?
In my view I’ve:
<%= add_titles(simple_format(truncate(@a1b, :length => 1450))) %>
And in my controller I’ve this:
def add_titles(a)
for a.each_line do |b|
if b.length < 100
print(b, :class => 'strong')
else
print b
end
end
end
Any thoughts? Cheers.
For anyone else stuck on this problem I’ve solved it by putting this logic into the pertinent views: