Limiting Size of Output Field

Hi!

I have a really stupid/simple question. How do you go about limiting
the size of a field for the output? For example, I have a field that
says…

<%= response.description %>

in my list.rhtml file. However, the description, at times, is rather
long. How can I limit it to say, 15 or so characters and then just
chop off the rest of the text?

Thanks!
Mike

I have a really stupid/simple question. How do you go about limiting
the size of a field for the output? For example, I have a field that
says…

<%= response.description %>

in my list.rhtml file. However, the description, at times, is rather
long. How can I limit it to say, 15 or so characters and then just
chop off the rest of the text?

truncate(response.description, 15)

truncate(text, length = 30, truncate_string = “…”)

If text is longer than length, text will be truncated to the length of
length and the last three characters will be replaced with the
truncate_string.

truncate(“Once upon a time in a world far far away”, 14)
=> Once upon a…

Just be careful about chopping it right in the middle of an html tag…

-philip

<%= response.description.to(15) %>

-Bill

[email protected] wrote:

chop off the rest of the text?

Thanks!
Mike


Sincerely,

William P.

Thank you very much Bill. That .to(15) did the trick…and so
easy. :slight_smile:

Thanks,
Mike