Mustache function & javascript

112 views
Skip to first unread message

Abdou B

unread,
Mar 10, 2016, 10:12:00 AM3/10/16
to mustache.java
Hello Guys,

 I juste start mustache.js a few days ago. 
I understand that mustache was built to be logic-less.
But I would like to use make treatment that will  require to use functions. 

I saw here and there the concept of functions. 
You define your functions in a JSON object and put it in the model/context of your templates. 

But it seems to me that you may use functions only when you built your model/context from Javascript code and not from java code. 
It is possible to define functions from Java code ? 
I try to put a string defining the JS function in a java String.

If that's the case I do not get the point to have functions. 
In my case I use java or Scala to run a program that built a mail from a template (html) and context/model ( an object ). 
What is the interest of functions if they are limited to js implementation ? 

Best Regards
Abdou 

Sam

unread,
Mar 26, 2016, 8:50:21 PM3/26/16
to mustache.java
They aren't. You can return an implementation of Function or TemplateFunction from your view fields / methods and it will be executed like it is in Javascript. You can look at the spec tests that show this behavior here:


Sam
Reply all
Reply to author
Forward
0 new messages