简体   繁体   中英

Java: Passing multiple values to handlebar template

I am using handlebar templates to prepare email content dynamically before sending over it.

It's straightforward to pass just one value. For example:

What's up {{this}} template workes fine with template.apply(firstName) .

Tried changing the template to What's up {{this}}, {{this}} and try to fill in by template.apply(lastName); and template.apply(firstName); .

But it doesn't work.

pass a map as parameter.

template.hbs

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

controll.java

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM