-
Notifications
You must be signed in to change notification settings - Fork 214
ac.partial.render() throws error for handlebar custom helper #1306
Comments
Hey, this is a limitation of handlebars and not an issue in mojito. Handlebars will not propagate context from parent to a partial, that's why all functions and data available at the regular template will not be available into the partial unless you use |
@caridy But it does work when I use ac.done() and the associated view uses the partial. ie instead of ac.partial.render () this works
Then what is the purpose of ac.partial ? From the naming it suggests that it's for manipulating partials but it cannot load html inside partials directory. Documentation - http://developer.yahoo.com/cocktails/mojito/api/classes/Partial.common.html#method_render - says for ac.partial.render() view has to be views folder, which makes me conclude that ac.partial is not for handlebar partials. My use-case if to instantiate this partial with new data, like in YUI template - http://yuilibrary.com/yui/docs/template/ |
@jithin1987 yes, now I understand what you want to do. First of all: Anyway, there is a bug in line 66 in the partial addon where the second argument should be just Feel free to send a PR or wait for us to get to that. /cc @lzhan |
@caridy Thank you very much for clarifying. One doubt I still have with partials is that, in Mojito is it possible to instantiate a view partial with data and render it, without having to include it in a view first ? ie in |
@jithin1987 yes, |
According to Mojito API: http://developer.yahoo.com/cocktails/mojito/api/classes/Partial.common.html#method_render, only putting partial view file directly under views dir is supported. I checked ac.partial.render(newData, 'task', ...) works fine. ac.partial.render(newData, './partials/task', ...) is not supported currently. |
…or both ac.done and ac.partial.render
Just verified: ac.partial.render(newData, 'partials/task', ...) should works (don't use './partials/task'). Plz try. |
@jithin1987 any update on this? |
@caridy @lzhan This still does not work for me.
Log Output
I do have this file |
I think I figured out what is happening, if I use any path other than partials it works. So my options here are to make this part of my mojit a child mojit or use a different view to have my content rendered there. |
And the easiest fix here for me is to do |
@jithin1987 @caridy : I just checked. |
Yes, I remember I added a rule to treat files under
I will sync up with the team later today and we can make a decision on this. @jithin1987 thanks again for the help to get the to bottom of this. |
Fix issue #1306: ac.partial.render() throws error for handlebar custom helper
…or both ac.done and ac.partial.render
Add this fix to next branch: Fix issue #1306: ac.partial.render() throws error for handlebar custom helper
Fix is available in mojito 0.8.3. |
I have a handlebar helper which is added via
When running
I get this error
Content of new-tasks.hb.html
Contents of ./partials/task.hb.html
On an additional note ac.partial.render() does not accept a handle bar view partial located inside partials/ folder which restricts it's use. Eg:
Gives an error saying cannot find ./partials/task'
The text was updated successfully, but these errors were encountered: