I am using the second option, but I had to create some external html files to avoid code duplication, with compose.
The first option i’ve tried and it does not work =(
I’ve also tried to use processContent, but I could manage this to work
I have a working version using an similar approach, but I really would like to use the if.bind in template, and not in other places too, because its is very weak, if developer forget to send the bind in card component I will not render like it should, so thats why I want to have this replacement based on the existence of the template with replace-part.
Thats my current version of something like you proposed
Nice to hear that you have a working version. Cheers
I would like to point out couple of things. First, when you say
…if developer forget to send the bind in card component I will not render like it should…
I see that as a documentation issue. Because the same argument applies to every custom elements with @bindables. I think this problem should be tackled with proper documentation.
Second, from your example it seems that the following is the fallback content of the side-action slot/part.
If that’s really the case, then we don’t even need the gymnastic with the whole if.bind just use it as the fallback content in the side-action slot/part.
Finally, as far as I remember, <template> are by default containerless. As long as you have a template controller like if, else, repeat.for etc. on it, the template content will be displayed.
If that’s really the case, then we don’t even need the gymnastic with the whole if.bind just use it as the fallback content in the side-action slot/part.
Thats the problem, it does not work.
If I add the <a> as a fallback value inside the empty template, it will always be overridden, no matter what if the “replace-part” is with an if.bind="false"
I see that as a documentation issue. Because the same argument applies to every custom elements with @bindable s. I think this problem should be tackled with proper documentation.
I dont agree, because I am working with the framework features, when some feature does not work, I have to create and workaround, and that is the problem.
With fallback I meant something like this: Dumber Gist. This example uses the <a> purely as a fallback. If you have no usage of the bindable condition in your card CE, other than controlling the fallback, then you can get rid of that like it is done in the example, and let the the replaceable fallback work as it should.
I understand. I think that’s not supported, and it is also unlikely that will be supported in Au2. In that case, the if-else in the CE itself is the best option IMO.
The reason it is unlikely to be supported in Au2 is that templating related to content projection is inherently a “compile” (this is the jit compilation of template, and not to be confused with the code comilation/bundler) time thing, as opposed to a “runtime” thing as usually expected with if-like template controller. @bigopon I believe that it is not much different for Au1 as well, right?
you don’t need containerless, since else/replaceable alone is already enough.
For the example
<my-element title="with replacement" link="foo-bar">
<template if.bind="false" replace-part="side-action">
<i>foo bar this should not have been shown</i>
</template>
</my-element>
The idea is replace-part template should be wrapping if:
alignment with compiler: the view compiler sees replace-part in a special way, so putting it a level above if makes you aware of that
good habit: placing multiple template controllers (if/else/repeat/containeless) on a single element works, but be careful with legacy Edge browser and IE, since they shuffle the attributes. You may not be able to predict the end result order of the attributes. If it feels good placing multiple template controllers on one element, then at least let replace-part wrap everything else.
The reason it is unlikely to be supported in Au2 is that templating related to content projection is inherently a “compile” (this is the jit compilation of template, and not to be confused with the code comilation/bundler) time thing, as opposed to a “runtime” thing as usually expected with if -like template controller. @bigopon I believe that it is not much different for Au1 as well, right?
Yes. Custom element content extraction & projection are done similarly.