The Scandlebars definition of a handlebars helper.
The recommended fashion in which to define a helper is as follows. HelperOptions.lookup returns an Option which will
evaluate to an empty string if the lookup does not yield a result.
It may be likely that you can predict the type of binding in practice. You could attempt to cast the context binding to
the type you expect. This runs the risk of throwing a ClassCastException while rendering the template, which may be
desirable. Use cautiously.
val fullNameHelper = Helper {
(binding, options) =>val person = binding.asInstanceOf[Person]
"%s %s".format(person.firstName, person.lastName)
}
The Scandlebars definition of a handlebars helper.
The recommended fashion in which to define a helper is as follows. HelperOptions.lookup returns an Option which will evaluate to an empty string if the lookup does not yield a result.
It may be likely that you can predict the type of binding in practice. You could attempt to cast the context binding to the type you expect. This runs the risk of throwing a ClassCastException while rendering the template, which may be desirable. Use cautiously.
See com.gilt.handlebars.scala.helper.HelperOptions for all of the options available.