Skip to content

Commit

Permalink
add each child template into a template tag
Browse files Browse the repository at this point in the history
  • Loading branch information
notthatjen committed Jun 8, 2024
1 parent 41c5756 commit 0ead842
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ export class Entity {
}

setEachItemTemplate() {
if (this.element.dataset.childTemplate) return
this.element.dataset.childTemplate = this.element.innerHTML
if (this.getEachItemTemplate()) return
const template = document.createElement('template')
template.innerHTML = this.element.innerHTML
template.id = "ChildTemplate:" + this.id
document.body.appendChild(template)
this.element.dataset.templateId = template.id
}

getEachItemTemplate() {
const template = document.createElement('template')
template.innerHTML = this.element.dataset.childTemplate
return template.content
const template = document.getElementById(this.element.dataset.templateId)
return template?.content
}

getClosestEl(attr) {
Expand Down

0 comments on commit 0ead842

Please sign in to comment.