ractive js nested templates not handled

24 views
Skip to first unread message

Tomer Zarfati

unread,
Jan 24, 2018, 9:18:07 AM1/24/18
to Ractive.js
Hello, 

I am trying to use nested templates using reactivejs in this jsfiddle


But I can't make the nested template to work, only the first level template is handled.

In the jsfiddle We can see that if the "template-input" is at the first level so it is handled, and if it under another template ("template-row") it is not handled

I saw the same question here: ractivejs component nesting but I didn't succeed make the answer to work.

Can someone help me with this?

Thank you very much!

Chris Reeves

unread,
Jan 24, 2018, 2:25:33 PM1/24/18
to Tomer Zarfati, Ractive.js
By default, components only have access to their constructor registries e.g. Ractive.defaults and any intermediate `Ractive.extends`, so the template row component can't access the template input component that is registered with the main instance. If you move the components to the global component registry (Ractive.components['template-input'] = ...), add a components map to the template row component, or turn off isolation on the template row component by passing `isolated: false` to `extend`, it will start working: https://jsfiddle.net/2hLzhwyd/4/

It _looks_ like what you're after is just template reuse though, which is what partials are designed for: https://jsfiddle.net/2hLzhwyd/5/
In addition to being simpler code, there's also significantly less overhead to a partial because it's just a chunk of template rather than an entire ractive instance with event, style, etc support.


Thanks, Chris

--
You received this message because you are subscribed to the Google Groups "Ractive.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ractive-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tomer Zarfati

unread,
Jan 25, 2018, 2:16:30 AM1/25/18
to Ractive.js
Great answer Chris, thank you very very much!


בתאריך יום רביעי, 24 בינואר 2018 בשעה 21:25:33 UTC+2, מאת Chris Reeves:


Thanks, Chris

To unsubscribe from this group and stop receiving emails from it, send an email to ractive-js+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages