Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Akash Srivastava for Inline styling in Rails 4 erb

Ok I guess I found a solution, using a truncate over html_safe that includes special characters was producing problems, when the entire text including the nbsp; and inline styling was cut short due to truncate.

Switching the order of html_safe and truncate somewhat solved the issue. Now it would truncate first and then apply html_safe. But still was producing undesirable results when total length including all special characters increased my truncate limit. A little effort produced a result which was almost correct.

html_safe(job_profile.description.truncate(100) +'&nbsp;&nbsp;<font color="#999">[ '+ truncate(list.join(', '), length: 100-(job_profile.description.length)) +' ]</font>')

Little more customisation, taking into accounts the three dots ... every truncate produces, and one would get the exact result as needed.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>