[stringtemplate-interest] Wrapping lines of text

Nicholas Dunn i82much at gmail.com
Tue Jan 12 14:48:44 PST 2010


Hi folks,

I'm writing some templates to generate source code.  Here's part of the
template in question:

/**
$description$
$if(author)$
@author $author$
$endif$
*/

Now, $description$ is an arbitrarily long String.  What is the best way to
get $description$ to return the $description$ field formatted to an
arbitrary number of characters per line?  Is using a custom format renderer
the best way?  e.g. something like

$description; format="fixedWidth,80"$

and then define a case statement in an AttributeRenderer that handles this:

public String toString(Object o, String formatName)   {
    if (formatName.startsWith("
fixedWidth,")) {
        // Return a String broken up with new lines at or about the number
of chars passed in.
    }
}

Is there a better way to do this?

Thanks

-- 
Nicholas Dunn
(207) 651-9839
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20100112/8c22cba5/attachment.html 


More information about the stringtemplate-interest mailing list