You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this is not a bug, more like a question and it's probably related to riot more than riotTS.
I'm wondering if it's possible that if I have a class which has a template to extend that class but be able to use the parent's template too.
The closest I could get to this was to use composition instead of inheritance and <yield/>.
So something like this:
@template(`
<mycomp>
<p>mycomp content</p>
<yield/>
</mycomp>
)
class MyComponent extends Riot.Element
{
// ....
}
// This kinda does what I need (except that MyChild doesn't inherit from MyComp):
`@template(`
<mychild>
<mycomp>test</mycomp>
</mychild>
)
class MyChild extends Riot.Element
{
// ...
}
// This doesn't work, the template override MyComponent's template and I couldn't find a way to be able to use the parent's template
`@template(`
<mychild>
<div>test</div>
</mychild>
)
class MyChild extends MyComponent
{
// ...
}
Or maybe I'm using a wrong approach and I shouldn't even try to do this?
The text was updated successfully, but these errors were encountered:
Yes @template is overridden because this is how classes are supposed to work. But perhaps in your case you just need to have a 3rd element which is a common ancestor for MyComp and MyChild, e.g.
Thank you that sounds reasonable. I just wanted to reuse the template of my parent class without having to rewrite it, but I will try to explain my use case better.
Hi Nino,
this is not a bug, more like a question and it's probably related to riot more than riotTS.
I'm wondering if it's possible that if I have a class which has a template to extend that class but be able to use the parent's template too.
The closest I could get to this was to use composition instead of inheritance and <yield/>.
So something like this:
Or maybe I'm using a wrong approach and I shouldn't even try to do this?
The text was updated successfully, but these errors were encountered: