Instances of classes implementing this interface bound to the module registry will be automatically
registered as handlebars helpers.
Example usage: (Java DSL)
import ratpack.handlebars.NamedHelper;
import com.github.jknack.handlebars.Options;
import ratpack.handling.*;
import ratpack.guice.*;
import ratpack.func.Action;
import ratpack.launch.*;
public class MultiplyHelper implements NamedHelper<String> {
public String getName() {
return "hello";
}
CharSequence apply(String context, Options options) throws IOException {
return String.format("Hello %s", context)
}
}
class ModuleBootstrap implements Action<ModuleRegistry> {
public void execute(ModuleRegistry modules) {
modules.bind(MultiplyHelper.class)
}
}
LaunchConfig launchConfig = LaunchConfigBuilder.baseDir(new File("appRoot"))
.build(new HandlerFactory() {
public Handler create(LaunchConfig launchConfig) {
return Guice.handler(launchConfig, new ModuleBootstrap(), new Action<Chain>() {
public void execute(Chain chain) {
}
});
}
});
Example usage: (Groovy DSL)
modules {
bind MultiplyHelper
}