SlexAxton / require-handlebars-plugin

A plugin for handlebars in require.js (both in dev and build)
804 stars 202 forks source link

Helpers not found when nested. #217

Closed rhogan73 closed 9 years ago

rhogan73 commented 9 years ago

It appears that when using a nested helper the code is falling back to handlebars instead of hbs.
<option value="omni" {{#if (toBool type '==' 'omni')}}selected{{/if}}>Omnivore</option> The helper is defined correctly because if I use the helper by itself, it registers correctly and no errors appear.

coderfin commented 9 years ago

I am also seeing the same or similar issue. Adding the following code in the recursiveVarSearch function right at the beginning of the _(statements).forEach loop seems to fix the issue.

var searchParamsForSexpr = function (params) {
    params.forEach(function (param) {
        if (param.type === 'sexpr' && param.isHelper === true) {
            helpersres.push(param.id.string);

            if (param.params) {
                searchParamsForSexpr(param.params);
            }
        }
    });
}

if (statement.params) {
    searchParamsForSexpr(statement.params);
}