Is there a way to bind variables and have mustache fail if not all 'required' variables are there?

69 views
Skip to first unread message

dhi...@twitter.com

unread,
May 25, 2017, 3:03:01 PM5/25/17
to mustache.java
I can do something like this if it is optional

{{#person?}}
  Hi {{name}}!
{{/person?}}

Many of our users define templates like "{{name}} says hi to {{salesperson}}" .  for the most part, we would not like to send out " says hi to " because the request did not have the right bindings and would rather discard it.  There are many templates and I have no idea of knowing what is inside a template.  Is there a way to 

1. create a template with a required field like {{%name}} that means required?  or is that not possible
2. to get mustache to blow up with an exception if the required parameter is bound with null or not bound at all

thanks,
Dean

Sam Pullara

unread,
May 25, 2017, 5:35:48 PM5/25/17
to mustac...@googlegroups.com
You can start with this test that shows how you can change the default missing behavior to whatever you like:

--
You received this message because you are subscribed to the Google Groups "mustache.java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mustachejava...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages