Support for templates which output pure text instead of html
98 views
Skip to first unread message
Dhiraj
unread,
Oct 26, 2016, 7:42:53 PM10/26/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mustache.java
Hi,
We would like to use mustache as our templating engine, but for us we want to use it as Object-to-Text conversion instead of Object-to-HTML conversion. I see that currently some of the characters are escaped using HTML escape chars, which would not work in the context of Object-to-Text conversion.
Are there any plans of adding this support? Or this is not an intended usecase of mustache?
Regards, Dhiraj
Dhiraj
unread,
Oct 26, 2016, 7:48:21 PM10/26/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mustache.java
I realized that this is already supported.
Saw this in the documentation:
All variables are HTML escaped by default. If you want to return
unescaped HTML, use the triple mustache: {{{name}}}.
You can also use & to unescape a variable: {{& name}}. This may be
useful when changing delimiters (see "Set Delimiter" below).
Sam
unread,
Nov 2, 2016, 4:26:05 PM11/2/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mustache.java
For convenience, you could instead override the encode() call on DefaultMustacheFactory and just have it write the value to the writer directly rather than its default behavior that HTML encodes. This will let you use double curlies instead so you don't have to worry about making an inadvertent error.