-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Content of nested template is empty #500
Comments
/sub |
If I could better understand the outcome you are looking for, maybe we could find a way to achieve it without trying to augment template machinery. |
Thanks, Then our partial/external template could look like: <!-- loaded and executed only once per partial -->
<script src="relative/to/this/file/external.js"></script>
<link rel="import"
href="path/polymer-ui-ratings.html">
<!-- stamped to main document and executed every time when `imported-template` is stamped -->
<template bind>
Template content with <strong>{{data}}</strong><polymer-ui-ratings value="5"></polymer-ui-ratings>
<script>
console.info("inline script executed when template is stamped, ");
</script>
</template> in your main document <template is="imported-template" content="/path/to/file.html"></template> and give some data model document.querySelector('template[is=imported-template]').model = {
data: "data binding"
}; So far this works https://github.com/Juicy/imported-template some examples here (there are still some minor bugs, but general concept is proved) But my biggest problem comes when I try to provide something similar to <template is="imported-template" content="/path/to/file.html">
<section><h2>Wrapped external template</h2>
<imported-content></imported-content>
</section>
</template> So, I need to access When I figured out that, there is |
Custom elements provide a lot of machinery to customize behavior. I suspect there are creative solutions in that space that don't necessitate changing primitive behavior of template. I'm sorry I can't be more concrete. If you are convinced that template behavior must be changed, please post a fresh issue on https://github.com/Polymer/templatebinding/issues. |
I'm not sure if it's a bug, template shim limitation, or desired behavior.
How can I get JS access to
.content
of nested<template>
?I'm trying to extend
<template>
with myimported-template
element (which fetches template content from external file) and I would like to implement<imported-content>
in similar manner to native<content>
. To do so, I simply trybut it occurred, that for nested template
this.content
is empty.JSFiddle
Stackoverflow
I thought it's because I use wrong life-cycle callback, so content is not yet/no longer there.
Therefore I tried
createdCallback
,attachedCallback
, and eventMutationObserver
(jsfiddle), but none of those helped.The text was updated successfully, but these errors were encountered: