View Single Post
Old 09-07-2014, 04:32 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,475
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
@rebl: You cannot nest functions in single function mode, what you called "simple" mode. It is also difficult to distinguish between an argument containing a comma and the argument separator comma. Because of this, you *really* want to use template program mode (TPM) or general program mode (GPM). Both give you the possibility of nesting function calls. Both distinguish between commas in strings and commas used as argument separators. TPM is better for small expressions needed in larger templates. GPM is better when complexity is high, when you want to be able to more easily read the code, or when constant strings in the template contain { and } characters.

Your example in GPM:
Code:
program:
	re(shorten(field('comments'), 50, '...', 50), '<.*?>','')
Your example in TPM:
Code:
{comments:'re(shorten($, 50, '...', 50), '<.*?>','')'}
In both cases HTML stripping won't work if the tag contains a string containing a > character. That situation is rather hard to deal with in regular expressions.

EDIT: trumped (somewhat) by eschwartz. To answer your question about how you "get into program mode", you simply begin the template with the word "program:"

Last edited by chaley; 09-07-2014 at 04:35 AM.
chaley is offline   Reply With Quote