Skip to content

Commit c5b7317

Browse files
committed
feat: render supports key and render attribute
1 parent cfd4a65 commit c5b7317

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ async function render({ source, element, selector, data, key, index, currentInde
7171
}
7272

7373
if (source) {
74+
if (!key)
75+
key = source.getAttribute('render') || source.getAttribute('key')
76+
7477
let sourceData = sources.get(source)
7578
if (!sourceData) {
7679
sourceData = { element: source, data }
@@ -80,6 +83,7 @@ async function render({ source, element, selector, data, key, index, currentInde
8083
source = sourceData
8184
if (!source.data)
8285
source.data = data
86+
8387
} else if (data)
8488
source = { data }
8589

@@ -100,8 +104,7 @@ async function render({ source, element, selector, data, key, index, currentInde
100104
element = [element]
101105

102106
for (let i = 0; i < element.length; i++) {
103-
if (!key)
104-
key = element[i].getAttribute('render') || type
107+
key = element[i].getAttribute('render') || key || type
105108

106109
let renderedNode = renderedNodes.get(element[i])
107110
if (source) {
@@ -530,9 +533,9 @@ async function renderValue(node, data, placeholder, renderAs, renderedNode) {
530533

531534
let match
532535
do {
533-
// match = output.match(/{{([A-Za-z0-9_.,\[\]\- ]*)}}/); // works by getting inner matches first
536+
match = output.match(/{{([A-Za-z0-9_.,\[\]\- ]*)}}/); // works by getting inner matches first
534537
// match = output.match(/{{([^}]*)}}/);
535-
match = output.match(/{{(.*?)}}/);
538+
// match = output.match(/{{(.*?)}}/);
536539
if (match) {
537540
let value
538541
try {

0 commit comments

Comments
 (0)