public class EmbeddedHelper extends Object implements Helper<String>
<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>
| Modifier and Type | Field and Description |
|---|---|
static Helper<String> |
INSTANCE
A singleton instance of this helper.
|
static String |
NAME
The helper's name.
|
| Constructor and Description |
|---|
EmbeddedHelper() |
| Modifier and Type | Method and Description |
|---|---|
Object |
apply(String path,
Options options)
Apply the helper to the context.
|
public static final String NAME
public Object apply(String path, Options options) throws IOException
Helperapply in interface Helper<String>path - The context object.options - The options object.IOException - If a template cannot be loaded.Copyright © 2022. All rights reserved.