This feature is experimental. Please share your experiences so we know what to keep or change.
Clones a template element.
Emits the up:template:clone
event. You can use that event to integrate template engines
like Mustache, EJS or Handlebars.
let { nodes } = up.template.clone('#table-placeholder')
up.render({ fragment: nodes })
Any template variables can be passed as a second argument:
let { nodes } = up.template.clone('#table-placeholder', { rows: 10 })
The element to clone.
This is usually a <template>
element or a <script>
with a custom type.
You may also pass a selector for the element to clone.
An object with template variables.
An optional origin element used for template lookup.
A list of Node
objects that represent
the cloned templates.
You can pass this link to any rendering function, like up.render()
or up.Preview#insert()
.