I have a title on a blog goes like this Main Idea, key term, key term, keyterm
I want the main idea and the key terms to have a different font sizes. First thing that came to mind was to search for the first comma and the end of the string and replace that chunk with the same thing but surrounded by span tags with a class to make the font smaller.
Here is the plan:
HTML (before)
<a href="stupidreqexquestion">Main Idea, key term, key term, key term</a>
HTML (after)
<a href="stupidreqexquestion">Main Idea <span class="smaller_font">, key term, key term key term</span></a>
I’m using Rails so I plan to add this as a helper function – for ex:
helper
def make_key_words_in_title_smaller(title)
#replace the keywords in the title with key words surrounded by span tags
end
view
<% @posts.each do |post |%>
<%= make_key_words_in_title_smaller(post.title)%>
<% end -%>
If you don’t care about the
Main Ideapart being"Welcome home, Roxy Carmichael", that is, with a comman within double quotes