Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to apply multiple helpers to a template in Handlebars?

I have two Handlebars helpers which I use.

First is timeboundset which takes an array and a datefield and only selects and applies those elements which fall after that datefield.

Second is sortedset which sorts the array first and then uses its elements.

Is there a way I can use both the helpers on the array in html itself and not doing any workaround in Javascript.?

like image 694
agaase Avatar asked May 03 '13 13:05

agaase


People also ask

What are partials in Handlebars?

Handlebars allows for template reuse through partials. Partials are normal Handlebars templates that may be called directly by other templates.

How do you make Handlebars for helpers?

Below there is an example of code which creates two super simple custom helpers which accept one argument: /* * Custom theme helpers for Handlebars. js */ let themeHelpers = { test1: function(value) { return "TEST1 " + value; }, test2: function(value) { return "TEST2 " + value; } }; module.

What are helpers in Handlebars How can you register it?

Helpers are basically regular functions that take the name of the helper with the helper function as arguments. You can register expression Helper by using the following code: Handlebars. registerHelper("last", function(array) { return array[array.

What are helpers in Handlebars?

Helpers can be used to implement functionality that is not part of the Handlebars language itself. A helper can be registered at runtime via Handlebars. registerHelper , for example in order to uppercase all characters of a string.


1 Answers

amwmedia commented on GitHub on Oct 7, 2014 that "this appears to have native support using something like:"

{{ helper1 (helper2 text) }}

It does indeed appear to work natively, without the need to register a helper. Note that the helper inside the () braces is executed first, the helper outside last:

{{ executesLast (executesFirst text) }}
like image 177
brandonscript Avatar answered Dec 07 '22 18:12

brandonscript