Mustache function & javascript

瀏覽次數:112 次
跳到第一則未讀訊息

Abdou B

未讀,
2016年3月10日 上午10:12:002016/3/10
收件者: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

未讀,
2016年3月26日 晚上8:50:212016/3/26
收件者: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
回覆所有人
回覆作者
轉寄
0 則新訊息