From d64590a12bf25c398145b128b40aa8865f908a83 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 11 Nov 2013 22:29:38 +0000 Subject: [PATCH] Fixed problem with target fields/index being erroneously applied to template See here for discussion: https://groups.google.com/d/msg/TiddlyWiki/D3MBNhjaT3E/ph0ZuAhuPFMJ --- .../wikiparser/rules/transcludeblock.js | 19 ++++++++++------- .../wikiparser/rules/transcludeinline.js | 21 ++++++++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/transcludeblock.js b/core/modules/parsers/wikiparser/rules/transcludeblock.js index c3f91c7a5..b1cfd6b4e 100644 --- a/core/modules/parsers/wikiparser/rules/transcludeblock.js +++ b/core/modules/parsers/wikiparser/rules/transcludeblock.js @@ -40,9 +40,7 @@ exports.parse = function() { var transcludeNode = { type: "element", tag: "$transclude", - attributes: { - tiddler: {type: "string", value: template || targetTitle} - }, + attributes: {}, isBlock: true }; var tiddlerNode = { @@ -54,11 +52,16 @@ exports.parse = function() { isBlock: true, children: [transcludeNode] }; - if(targetField) { - transcludeNode.attributes.field = {type: "string", value: targetField}; - } - if(targetIndex) { - transcludeNode.attributes.index = {type: "string", value: targetIndex}; + if(template) { + transcludeNode.attributes.tiddler = {type: "string", value: template}; + } else { + transcludeNode.attributes.tiddler = {type: "string", value: targetTitle}; + if(targetField) { + transcludeNode.attributes.field = {type: "string", value: targetField}; + } + if(targetIndex) { + transcludeNode.attributes.index = {type: "string", value: targetIndex}; + } } return [tiddlerNode]; }; diff --git a/core/modules/parsers/wikiparser/rules/transcludeinline.js b/core/modules/parsers/wikiparser/rules/transcludeinline.js index ae21e67c3..c17ae0eb8 100644 --- a/core/modules/parsers/wikiparser/rules/transcludeinline.js +++ b/core/modules/parsers/wikiparser/rules/transcludeinline.js @@ -40,9 +40,8 @@ exports.parse = function() { var transcludeNode = { type: "element", tag: "$transclude", - attributes: { - tiddler: {type: "string", value: template || targetTitle} - } + attributes: {}, + isBlock: true }; var tiddlerNode = { type: "element", @@ -50,13 +49,19 @@ exports.parse = function() { attributes: { tiddler: {type: "string", value: targetTitle} }, + isBlock: true, children: [transcludeNode] }; - if(targetField) { - transcludeNode.attributes.field = {type: "string", value: targetField}; - } - if(targetIndex) { - transcludeNode.attributes.index = {type: "string", value: targetIndex}; + if(template) { + transcludeNode.attributes.tiddler = {type: "string", value: template}; + } else { + transcludeNode.attributes.tiddler = {type: "string", value: targetTitle}; + if(targetField) { + transcludeNode.attributes.field = {type: "string", value: targetField}; + } + if(targetIndex) { + transcludeNode.attributes.index = {type: "string", value: targetIndex}; + } } return [tiddlerNode]; };