@webmate-studio/builder 0.2.109 → 0.2.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/template-processor.js +18 -3
package/package.json
CHANGED
|
@@ -299,8 +299,9 @@ class TemplateProcessor {
|
|
|
299
299
|
loopContext[arrayName] = arrayValue;
|
|
300
300
|
itemHtml = this.processClassConditionals(itemHtml, loopContext);
|
|
301
301
|
|
|
302
|
-
// First: Replace attribute expressions with quoted values (e.g., alt={item.image.alt} → alt="value")
|
|
303
|
-
|
|
302
|
+
// First: Replace attribute expressions with quoted values (e.g., alt={item.image.alt} or alt="{item.image.alt}" → alt="value")
|
|
303
|
+
// Pattern matches both: attr={expr} and attr="{expr}"
|
|
304
|
+
itemHtml = itemHtml.replace(new RegExp(`(\\w+)=["']?\\{\\s*${loopVar}\\.([a-zA-Z0-9_.]+)\\s*\\}["']?`, 'g'), (m, attrName, path) => {
|
|
304
305
|
// Navigate through nested path (e.g., "image.src")
|
|
305
306
|
const pathParts = path.split('.');
|
|
306
307
|
let value = item;
|
|
@@ -312,8 +313,13 @@ class TemplateProcessor {
|
|
|
312
313
|
value = value[part];
|
|
313
314
|
}
|
|
314
315
|
|
|
316
|
+
// Handle link objects (from LinkField) - extract path for preview/production
|
|
317
|
+
if (typeof value === 'object' && value !== null && value.type === 'page' && value.pageUuid) {
|
|
318
|
+
// In preview mode: use /preview/{pageUuid}
|
|
319
|
+
value = `/preview/${value.pageUuid}`;
|
|
320
|
+
}
|
|
315
321
|
// Handle image objects - extract URL
|
|
316
|
-
if (typeof value === 'object' && value !== null && (value.src || value.filename)) {
|
|
322
|
+
else if (typeof value === 'object' && value !== null && (value.src || value.filename)) {
|
|
317
323
|
value = value.src || value.filename || '';
|
|
318
324
|
}
|
|
319
325
|
|
|
@@ -343,6 +349,11 @@ class TemplateProcessor {
|
|
|
343
349
|
value = value[part];
|
|
344
350
|
}
|
|
345
351
|
|
|
352
|
+
// Handle link objects (from LinkField) - extract path for preview
|
|
353
|
+
if (typeof value === 'object' && value !== null && value.type === 'page' && value.pageUuid) {
|
|
354
|
+
return `/preview/${value.pageUuid}`;
|
|
355
|
+
}
|
|
356
|
+
|
|
346
357
|
// Handle image objects - extract URL
|
|
347
358
|
if (typeof value === 'object' && value !== null && (value.src || value.filename)) {
|
|
348
359
|
return value.src || value.filename || '';
|
|
@@ -412,6 +423,10 @@ class TemplateProcessor {
|
|
|
412
423
|
if (result === undefined || result === null) {
|
|
413
424
|
return '';
|
|
414
425
|
}
|
|
426
|
+
// Handle link objects (from LinkField) - extract path for preview
|
|
427
|
+
if (typeof result === 'object' && result !== null && result.type === 'page' && result.pageUuid) {
|
|
428
|
+
return `/preview/${result.pageUuid}`;
|
|
429
|
+
}
|
|
415
430
|
// Handle image objects
|
|
416
431
|
if (typeof result === 'object' && result !== null && (result.src || result.filename)) {
|
|
417
432
|
return result.src || result.filename || '';
|