2016-02-02 44 views
0

我正在使用句柄模板在发送之前动态地准备电子邮件内容。Java:将多个值传递给句柄模板

只传递一个值很简单。例如:

What's up {{this}}模板工作正常template.apply(firstName)

尝试将模板更改为What's up {{this}}, {{this}}并尝试填写template.apply(lastName);template.apply(firstName);

但它不起作用。

回答

0

您必须通过名称引用您在this对象上设置的变量。

What's up {{firstName}}, {{lastName}} 
+0

'handleBar'不工作的方式。你介意一点点阐述你的回答吗? –

+0

是handlebars.java与handlebars.js有什么不同? –

1

传递一个map作为参数。

template.hbs

What's up {{firstName}}, {{lastName}} 

controll.java

template.apply(new HashMap<String, Object>() { 
    { 
     put("firstName", "Himanshu"); 
     put("lastName", "Yadav"); 
    } 
});