Skip to content

Commit

Permalink
fix: handeling of render-as $auto
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Oct 27, 2024
1 parent 2ad239b commit 017dd71
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ async function renderTemplate(template, data, key, index, keyPath) {

for (let i = 0; i < renderData.length; i++) {
let clone = cloneTemplate(template);

let test = clone.element.getAttribute('render-as')
if (test)
renderAs = test

clone.keyPath = template.keyPath || '' + `[${i}]`

let object
Expand Down Expand Up @@ -386,7 +391,8 @@ function cloneTemplate(template) {
clone.setAttribute('render-clone', '');

let renderAs = clone.getAttribute('render-as')
if (renderAs) {
if (renderAs === '$auto') {
renderAs = uuid.generate(6)
clone = clone.outerHTML.replace(/\$auto/g, renderAs);
}

Expand Down Expand Up @@ -432,7 +438,7 @@ function insertElement(template, element, index, currentIndex, data, renderRever
item = clones.splice(currentIndex, 1)[0];
}

if (data.$filter && data.$filter.startingIndex)
if (data && data.$filter && data.$filter.startingIndex)
index += data.$filter.startingIndex
clones.splice(index, 0, item); // Insert item into clones at the specified index

Expand Down

0 comments on commit 017dd71

Please sign in to comment.