[stringtemplate-interest] Wrapping lines of text
Terence Parr
parrt at cs.usfca.edu
Tue Jan 12 14:55:26 PST 2010
yep, something like that, though see if the toString() arg to StringTemplate is visible to the renderer. you can save the parameter.
Ter
On Jan 12, 2010, at 2:48 PM, Nicholas Dunn wrote:
> 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
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list