2

As per the Handlebars.java documentation, there is an Options class which has a params object that can be accessed. My question is, how do I write a template + input JSON, which will populate this Options.param object?

API Documentation that shows Options param function: http://javadox.com/com.github.jknack/handlebars/1.3.1/com/github/jknack/handlebars/Options.java.html

Janac Meena
  • 3,203
  • 35
  • 32

1 Answers1

2

Found my own answer. Options are specified in the template, not in the input data. Any params passed to a helper function, after the context argument, will be options. For example:

Template:

{{yourHelperFunction context "option1" "option2"}}

Input data:

{ 

    "someData" :"data" 

} 

Java code:


    public yourHelperFunction(String context, Option options){
        if (options.param(0) == "option1") /*do something */
    }

Janac Meena
  • 3,203
  • 35
  • 32