ahoy all,
as you can see from this simple JSFiddle i am having a problem using the result of a helper in a sub expression as input to another helper. with the following helpers:
Handlebars.registerHelper("findRoot", (path, helperData) ->
newRoot = path.split("/")[0..1].join("/")
return new Handlebars.SafeString(newRoot))
Handlebars.registerHelper("rebase", (path, root, helperData) ->
return new Handlebars.SafeString(root + path))
template:
{{#each pages}}
findRoot = {{findRoot base}}</br>
rebase = {{rebase ID.path (findRoot base) option=false}}</br>
{{/each}}
and context:
context =
pages: [
{base: "/Root/A", ID: {path: "/A/1"}},
{base: "/Root/B", ID: {path: "/B/2"}}
]
the return value of the findRoot helper when used as a sub expression is being fed as an object to rebase instead of as a string. note that when findRoot is run normally (not as a sub expression) the return value is a string and everyone is happy.
i have tried with/without Handlebars.SafeString and no luck. i debugged it as far as the Handlebars compiler which builds the stack/depth stuff under the hood and did not see anything obviously amiss.
it seems like for some reason the entire ID object is getting passed in where i assume the string returned from findRoot should be?!
while i realize that i most likely i am not using Handlebars correctly, i have been digging at this for quite a bit and am beginning to think that maybe there is something going on here, like a bug?
thanks in advance for any help.
ahoy all,
as you can see from this simple JSFiddle i am having a problem using the result of a helper in a sub expression as input to another helper. with the following helpers:
template:
and context:
the return value of the
findRoothelper when used as a sub expression is being fed as an object torebaseinstead of as a string. note that whenfindRootis run normally (not as a sub expression) the return value is a string and everyone is happy.i have tried with/without
Handlebars.SafeStringand no luck. i debugged it as far as the Handlebars compiler which builds the stack/depth stuff under the hood and did not see anything obviously amiss.it seems like for some reason the entire
IDobject is getting passed in where i assume the string returned fromfindRootshould be?!while i realize that i most likely i am not using Handlebars correctly, i have been digging at this for quite a bit and am beginning to think that maybe there is something going on here, like a bug?
thanks in advance for any help.