pledbrook / lazybones

A simple project creation tool that uses packaged project templates.
Apache License 2.0
614 stars 102 forks source link

The String Literal "\n" gets transformed into a new line. #143

Open AndrewReitz opened 9 years ago

AndrewReitz commented 9 years ago

I have out.write("\n"); in a template file. When creating a new project from this template. The out.write("\n"); is changed to

out.write("
");
pledbrook commented 9 years ago

This is just one of those things when using the default Groovy template engine. You need to escape any $ and \ in the template. I'll keep this open as a documentation issue.

In your particular case, you can either use out.write("\\n") or switch to Handlebars JavaScript templates, which don't have the same requirement. I lean towards using Handlebars for templates of Java and Groovy source files.

AndrewReitz commented 9 years ago

Thanks, this makes a lot of sence. I've been doing replacements in files that have $, but switching the template engine seems a lot easier.