I am using Rythm (yup no h), a Java template engine.
The idea is to replace placeholders in a template file (e.g. a text file).
In my case I am dealing with JSON. To call the Rythm engine I only need to do:
Rythm.render("my @var1 content and my email is joe@acme (or call @var2)", "foo", "bar");
The output is
[DEBUG] org.rythmengine.RythmEngine:69 - Rythm-1.1.1- SNAPSHOT started in prod mode
my foo content and my email is joebar (or call )
[ INFO] org.rythmengine.RythmEngine:84 - Shutting down Rythm Engine: [re-wZ5]
As you can see the value "bar"
went to @acme which the engine mistook for a placeholder. How can I escape the @ sign?
Thanks
You can double the @
to escape it:
joe@acme
=> joe@@acme
Checkout document at http://rythmengine.org/doc/template_guide.md#at
System.out.println(Rythm.render("my @var1 content and my email is joe@@acme.com (or call @var2)", "foo", "bar", "foo", "bar"));
yields
[DEBUG] org.rythmengine.RythmEngine:69 - Rythm-1.1.1-SNAPSHOT started in prod mode
my foo content and my email is [email protected] (or call bar)
[ INFO] org.rythmengine.RythmEngine:84 - Shutting down Rythm Engine: [re-pI7]