Hi! I’m writing a piece of code that tries to truncate the amount of
text displayed in the cell to restrict it such that the formatting
doesn’t spoil if the string is too long.
What I want to do is:
- If the ‘met_person’ string is longer than 20 characters, I want to
pick the first 18 and add “…” to it and display that in the cell.
- Also, I want to use the title attribute for the cell so that a mouse
over shows the full text.
- If the name is shorter than 20 characters, it is fine - just display
So, right now, I have something like this which works (I guess it can be
I’d like to make this a generic helper that automatically truncates
the text. So, should I put in a helper file? So, this could be
something like truncate_text(meeting.met_person, 20) and the function
could do the check and return the correct string.
Since there is sufficient repetition to create the title and the text
in the cell, it may be nice to create something that creates the full
HTML code, rather than just the string. Where would that go? Would
that be a helper too?