[stringtemplate-interest] Remove carriage returns
John Snyders
jjsnyders at rcn.com
Wed Jan 24 10:31:27 PST 2007
Because the source contains CRLF and the output just LF it makes me think
that this is an OS new line convention issue. If so you might try a source
editor that is happy with just LF as new line. Many code editors can be
configured for this. Then your source would just have LF in it and no need
for any transformation.
StringTemplate allows you to create your own StringTemplateWriter. This
gives you final control over the output. You should be able to strip CR at
this point. The advantage is that you don't have to wait for the whole
output to be available. You can pipe the output of your template directly to
the consumer. Look at NoIndentWriter and AutoIndentWriter implementation for
ideas. I have not created my own Writer yet.
Another option would be to preprocess the template to remove CR before
invoking the templates. There are various dos2unix commandline tools for
this. You can make it part of the build.
-John
> -----Original Message-----
> From: stringtemplate-interest-bounces at antlr.org
> [mailto:stringtemplate-interest-bounces at antlr.org]On Behalf Of
> brian.kejser at protexis.com
> Sent: Wednesday, January 24, 2007 1:00 PM
> To: stringtemplate-interest at antlr.org
> Subject: [stringtemplate-interest] Remove carriage returns
>
>
> Hi
>
> In order to make a template human readable during editing I need to
> include both carriage returns and line feeds in the document. When
> rendering the template I need all carraige returns removed or the consumer
> of the output throws an error. I currently render the template then do a
> string replace to resolve this issue.
>
> Is there a cleaner way? That is, can I instruct the template engine to
> drop all carriage returns during rendering?
>
> Thanks
>
>
>
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list