Well, the reason for the alternative approach is that he didn't specify why
he wanted to truncate the description. Typically, this is due to layout and
not necessarily content. Also, counting words breaks down as soon as you
introduce html into the mix, because it is very easy to lop off closing
t
I think the point is that he's trying to truncate the text in a meaningful
way, such as at the end of a sentence.
One way around "4.5 houses" is to only use a period as a delimiter if it is
followed by at least one space and an uppercase letter. It's not perfect of
course, but it would eliminate m
Another option would be to place the entire description in a div and then
truncate it via css.
http://www.w3schools.com/cssref/css3_pr_text-overflow.asp
On Sat, Mar 7, 2015 at 1:31 AM, Mark Spence wrote:
>
> I have a long product description I am trying to truncate. I could just
> truncate it
just keep in mind that periods exist in text for other reasons than
ending sentences - this code will NOT always work as intended
This will kill your desired end result "There are 4.5 houses finished." ;-)
SorryI don't have a solution handy - just spotted a potential issue
Take care
-Brya
Might be something to test, but first look if there is no period on a
string +200, I don't believe anything will return.
Another method might be to use reMatch to break the string into an array of
sentences. Then loop over the returned array, concatenating the string back
together until length >
Variable I is undefined.
This works,
#variables.description#
On Sat, Mar 7, 2015 at 1:31 AM, Mark Spence wrote:
>
> I have a long product description I am trying to truncate. I could just
> truncate it, but I don't want to break off sen
I have a long product description I am trying to truncate. I could just
truncate it, but I don't want to break off sentences. Here is the solution
I came up with but it does not seem to have any effect.
Any ideas?
~
7 matches
Mail list logo