feat: add custom placeholder mapping for non-standard templates

Added optional placeholderMapping to project.json for templates that
don't follow the standard ITEM_{PROPERTY} convention.

Features:
- Override default placeholder names per field
- Useful for legacy templates or migration from other tools
- Fallback to ITEM_{PROPERTY} convention when not specified

Example usage:
{
  "fieldMapping": {
    "id": "ID",
    "title": "Title"
  },
  "placeholderMapping": {
    "id": "TASK_ID",     // Use {{TASK_ID}} instead of {{ITEM_ID}}
    "title": "TASK_NAME" // Use {{TASK_NAME}} instead of {{ITEM_TITLE}}
  }
}

Changes:
- generator.js: Check for cfg.placeholderMapping before using default
- Added 2 new tests for custom mapping behavior
- Updated TEMPLATE_V2_GUIDE.md with documentation and examples

All 58 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-28 03:24:33 +01:00
parent 2bab447fa8
commit b5e4550efd
3 changed files with 76 additions and 1 deletions

View File

@@ -173,9 +173,11 @@ window.timelineGenerator = {
};
// Dynamically add data placeholders from all item properties
const placeholderMapping = cfg.placeholderMapping || {};
for (const [key, value] of Object.entries(it)) {
if (key !== 'due') { // Skip due date as it's used for positioning
const placeholderName = `ITEM_${key.toUpperCase()}`;
// Use custom placeholder name if defined, otherwise use convention
const placeholderName = placeholderMapping[key] || `ITEM_${key.toUpperCase()}`;
itemValues[placeholderName] = this.escapeXml(value || "");
}
}