[stringtemplate-interest] Output formatting issue
Terence Parr
parrt at cs.usfca.edu
Tue May 24 16:34:07 PDT 2005
On May 18, 2005, at 7:11 AM, <ilia at obnovlenie.ru>
<ilia at obnovlenie.ru> wrote:
>
> Independency from data type is nice, but sometimes output is to be
> formatted.
> Escaping ( < -> < etc.) is a programmer-controlled feature, but
> other
> formatters may need designer's control.
Correct.
> For example, date in the form of UNIX timestamp should be formatted
> according to designers' needs.
> In existing templates that can be something like
> {$date|date_format:"Y/m/d"}
>
> Or a long "topic header" is to be truncated to 40 symbols and then
> "..." is
> added at the end if it was truncated
> {$header|truncate:40:"..."}.
>
> The whole issue is about "variable modifiers" that are to be
> managed by
> designers.
> A programmer should not embed such things into code, because they
> refer to
> view rather than model.
Correct.
> Does StringTemplate support anything like that?
It relies on the controller to wrap objects in the appropriate
"renderer" object. I'm adding a mapping concept in the next version
that lets you pass in a collection of renderers, one for each locale,
so you could generically say format dates in this way. :)
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
More information about the stringtemplate-interest
mailing list