com.github.jknack.handlebars.helper
Class EmbeddedHelper

java.lang.Object
  extended by com.github.jknack.handlebars.helper.EmbeddedHelper
All Implemented Interfaces:
Helper<String>

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
Author:
edgar.espina

Field Summary
static Helper<String> INSTANCE
          A singleton instance of this helper.
static String NAME
          The helper's name.
 
Constructor Summary
EmbeddedHelper()
           
 
Method Summary
 CharSequence apply(String path, Options options)
          Callback method for execute the given method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final Helper<String> INSTANCE
A singleton instance of this helper.


NAME

public static final String NAME
The helper's name.

See Also:
Constant Field Values
Constructor Detail

EmbeddedHelper

public EmbeddedHelper()
Method Detail

apply

public CharSequence apply(String path,
                          Options options)
                   throws IOException
Description copied from interface: Helper
Callback method for execute the given method.

Specified by:
apply in interface Helper<String>
Parameters:
path - The context object (param=0).
options - The options object.
Returns:
A string result.
Throws:
IOException - If a template cannot be loaded.


Copyright © 2012. All Rights Reserved.