-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaceable templates not working across multiple levels #625
Comments
At the moment replaceable parts are single level. |
@StrahilKazlachev the first example is actually designed to be single level if the templates are replaced top-down. |
By single level I meant direct. In the first example you are targeting from |
Also looking for this feature! https://discourse.aurelia.io/t/render-template-within-template-within-element/2221 |
I'm uncertain whether we can support this feature. Consider the following example:
<template>
<div replaceable part="part-1">
<div replaceable part="part-1a">Part 1a</div>
<div replaceable part="part-1b">Part 1b</div>
</div>
<div replaceable part="part-2">
<div replaceable part="part-2a">Part 2a</div>
<div replaceable part="part-2b">Part 2b</div>
</div>
</template> What we are seeing here is 2 levels deep replaceable templates, with <template>
<a>
<template replace-part="part-1">...</template>
</a>
</template> The moment we replace <div replaceable part="part-1"> <!-- if this is replaced -->
<!-- all the following are gone, no trace of what to replace inside -->
<div replaceable part="part-1a">Part 1a</div>
<div replaceable part="part-1b">Part 1b</div>
</div> This is like assigning a new object to a property, there is no way to know what old properties there were for reconciliation. In case that we know all to-be-replaced parts of the destination, and all provided parts to replace them, what should be done with non-replaceable parts?
<template>
<div replaceable part="part-1">
<!-- what should be done for this -->
<h1>Not replaceable 1</h1>
<div replaceable part="part-1a">Part 1a</div>
<div replaceable part="part-1b">Part 1b</div>
</div>
<div replaceable part="part-2">
<!-- what should be done for this -->
<h1>Not replaceable 2</h1>
<div replaceable part="part-2a">Part 2a</div>
<div replaceable part="part-2b">Part 2b</div>
</div>
</template> For the above template, maybe thoughts ? @Mobe91 @StrahilKazlachev @JoshMcCullough @fkleuver @EisenbergEffect |
@bigopon If you add a (failing or passing) test for it in the vNext repo I can debug and see what might be needed to make it work, or establish whether it's possible at all (and give solid reasoning why not, if not). |
@bigopon If you have chosen to replace Additionally, you added the |
@fkleuver @JoshMcCullough I would imagine something like this
<template>
<div replaceable part="part-1">
<h1>Not replaceable 1</h1>
<div replaceable part="part-1a">Part 1a</div>
<div replaceable part="part-1b">Part 1b</div>
</div>
<div replaceable part="part-2">
<h1>Not replaceable 2</h1>
<div replaceable part="part-2a">Part 2a</div>
<div replaceable part="part-2b">Part 2b</div>
</div>
</template> Case 1: I want to replace
|
So I wouldn't think you'd use I think all of your examples are correct in your latest comment. And it's up to the user to decide if they are replacing the outer or inner parts in this case. Aurelia could potentially raise an error/warning if a user tried to do this )using your example) ...
|
@bigopon With regard to your example I would expect this to behave like @JoshMcCullough described. But I don't see how your example relates to my original one because you don't really have nested templates but rather just nested replacement points within a single template.. While I understand that multi-level replacement is not supported right now I feel that it should be possible to support it by just processing the replacement points top-to-bottom and by reprocessing each intermediate replacement result. When I apply such an algorithm to version 1 of my original example, I end up with the correct end result:
<template>
<tab-control>
<tab>
<template replace-part="tab1-content">
<template replaceable part="tab1"></template>
</template>
</tab>
</tab-control>
</template>
<template>
<tab-control>
<tab>
<template replace-part="tab1-content">
<form>...</form>
</template>
</tab>
</tab-control>
</template>
<template>
<tab-control>
<tab>
<div class="title">Tab-Title</div>
<template replaceable part="tab1-content"></template>
</tab>
</tab-control>
</template>
<template>
<tab-control>
<tab>
<div class="title">Tab-Title</div>
<form>...</form>
</tab>
</tab-control>
</template> |
Replaceable templates accross multiple levels as shown in the following sketch are not working. The replaceable template in
tab.html
gets replaced with empty content.tab.html
tab-control.html
app.html
Neither works this:
tab.html
tab-control.html
app.html
The text was updated successfully, but these errors were encountered: