1

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.

Himanshu Yadav
  • 13,315
  • 46
  • 162
  • 291

2 Answers2

2

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");
    }
});
Jiho Park
  • 21
  • 2
-1

You have to refer to the variables you set on the this object by their name.

What's up {{firstName}}, {{lastName}}
Blake Yarbrough
  • 2,286
  • 1
  • 20
  • 36