Class EmbeddedHelper
- java.lang.Object
-
- com.github.jknack.handlebars.helper.EmbeddedHelper
-
public class EmbeddedHelper extends Object implements Helper<String>
Given: home.hbs<html> ... {{emdedded "user" ["id"]}} </html>
where user.hbs is:<tr> <td>{{firstName}}</td> <td>{{lastName}}</td> </tr>
expected output is:<script id="user-hbs" type="text/x-handlebars-template"> <tr> <td>{{firstName}}</td> <td>{{lastName}}</td> </tr> </script>
Optionally, a user can set the template's name:{{emdedded "user" "user-tmpl" }}
expected output is:<script id="user-tmpl" type="text/x-handlebars-template"> <tr> <td>{{firstName}}</td> <td>{{lastName}}</td> </tr> </script>
- Since:
- 0.3.0
-
-
Constructor Summary
Constructors Constructor Description EmbeddedHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharSequence
apply(String path, Options options)
Apply the helper to the context.
-
-
-
Field Detail
-
NAME
public static final String NAME
The helper's name.- See Also:
- Constant Field Values
-
-
Method Detail
-
apply
public CharSequence apply(String path, Options options) throws IOException
Description copied from interface:Helper
Apply the helper to the context.- Specified by:
apply
in interfaceHelper<String>
- Parameters:
path
- The context object.options
- The options object.- Returns:
- A string result.
- Throws:
IOException
- If a template cannot be loaded.
-
-