diff --git a/js/WikiStore.js b/js/WikiStore.js index d3ca25b07..4d1ebd304 100755 --- a/js/WikiStore.js +++ b/js/WikiStore.js @@ -349,7 +349,7 @@ WikiStore.prototype.renderTiddler = function(targetType,title,asTitle,options) { return {}; }); if(tiddler) { - if(asTitle) { + if(asTitle && asTitle !== title) { var asTiddler = this.getTiddler(asTitle); return stitcher("div",{ "data-tw-render-tiddler": title, diff --git a/js/macros/tiddler.js b/js/macros/tiddler.js index e78818640..4ebdf304a 100644 --- a/js/macros/tiddler.js +++ b/js/macros/tiddler.js @@ -49,23 +49,38 @@ exports.macro = { types: ["text/html","text/plain"], cascadeParams: true, // Cascade names of named parameters to following anonymous parameters params: { - target: {byName: "default", type: "tiddler", optional: false}, + target: {byName: "default", type: "tiddler", optional: true}, + template: {byName: true, type: "tiddler", optional: true}, "with": {byName: true, type: "text", optional: true, dependentAll: true} }, handler: function(type,tiddler,store,params) { + var renderTitle = params.template, + renderAs = params.target; + // Slightly bewildering logic to sort out the optional parameters + if(renderAs === undefined) { + if(renderTitle === undefined) { + return ""; + } else { + renderAs = tiddler.title; + } + } else { + if(renderTitle === undefined) { + renderTitle = renderAs; + } + } if(params["with"]) { // Parameterised transclusion - var targetTiddler = store.getTiddler(params.target), + var targetTiddler = store.getTiddler(renderTitle), text = targetTiddler.text; var withTokens = [params["with"]]; for(var t=0; t
SixthTiddler

11 February 2011

Jermolene


SixthTiddler

11 February 2011

Jermolene


EighthTiddler




FirstTiddler




\ No newline at end of file diff --git a/test/wikitests/EighthTiddler.tid b/test/wikitests/EighthTiddler.tid new file mode 100644 index 000000000..8e07e3a2c --- /dev/null +++ b/test/wikitests/EighthTiddler.tid @@ -0,0 +1,6 @@ +title: EighthTiddler + +<> +<> +<> +<> diff --git a/test/wikitests/EighthTiddler.txt b/test/wikitests/EighthTiddler.txt new file mode 100644 index 000000000..25ff931b0 --- /dev/null +++ b/test/wikitests/EighthTiddler.txt @@ -0,0 +1 @@ +SixthTiddler11 February 2011JermoleneSixthTiddler11 February 2011JermoleneEighthTiddlerFirstTiddler \ No newline at end of file diff --git a/test/wikitests/Fourth Tiddler.html b/test/wikitests/Fourth Tiddler.html index 6bd2c4f21..32b13b93c 100644 --- a/test/wikitests/Fourth Tiddler.html +++ b/test/wikitests/Fourth Tiddler.html @@ -1 +1 @@ -
An image
and a $1 couple of Ç Ç "HTML Entity" and macro
5.0.0
\ No newline at end of file +
A missing image
and a $1 couple of Ç Ç "HTML Entity"
\ No newline at end of file diff --git a/test/wikitests/Fourth Tiddler.tid b/test/wikitests/Fourth Tiddler.tid index 3e03f7583..351f4c4e9 100644 --- a/test/wikitests/Fourth Tiddler.tid +++ b/test/wikitests/Fourth Tiddler.tid @@ -1,3 +1,3 @@ title: Fourth Tiddler -An image [img[Something.jpg]] and a $1 couple of Ç Ç "HTML Entity" and macro <> \ No newline at end of file +A missing image [img[Something.jpg]] and a $1 couple of Ç Ç "HTML Entity" \ No newline at end of file diff --git a/test/wikitests/Fourth Tiddler.txt b/test/wikitests/Fourth Tiddler.txt index fa95b0513..4bf86005c 100644 --- a/test/wikitests/Fourth Tiddler.txt +++ b/test/wikitests/Fourth Tiddler.txt @@ -1 +1 @@ -An image and a $1 couple of Ç Ç "HTML Entity" and macro 5.0.0 \ No newline at end of file +A missing image and a $1 couple of Ç Ç "HTML Entity" \ No newline at end of file diff --git a/test/wikitests/SeventhTiddler.tid b/test/wikitests/SeventhTiddler.tid index 58c3717eb..78f640612 100644 --- a/test/wikitests/SeventhTiddler.tid +++ b/test/wikitests/SeventhTiddler.tid @@ -5,7 +5,3 @@ title: SeventhTiddler <> <> - -<> - -<> diff --git a/test/wikitests/SixthTiddler.html b/test/wikitests/SixthTiddler.html index 982b5e41d..6fbfcaec5 100644 --- a/test/wikitests/SixthTiddler.html +++ b/test/wikitests/SixthTiddler.html @@ -1 +1 @@ - \ No newline at end of file +
SixthTiddler

11 February 2011


\ No newline at end of file diff --git a/test/wikitests/SixthTiddler.txt b/test/wikitests/SixthTiddler.txt index 77d4b9e5b..1b83787ec 100644 --- a/test/wikitests/SixthTiddler.txt +++ b/test/wikitests/SixthTiddler.txt @@ -1 +1 @@ -SixthTiddler11 February 2011JermoleneFifth TiddlerFirstTiddlerFourth TiddlerSecondTiddlerSeventhTiddlerSixthTiddlerThirdTiddler \ No newline at end of file +SixthTiddler11 February 2011Jermolene \ No newline at end of file diff --git a/test/wikitests/ThirdTiddler.html b/test/wikitests/ThirdTiddler.html index 428019157..c9c8ed76b 100644 --- a/test/wikitests/ThirdTiddler.html +++ b/test/wikitests/ThirdTiddler.html @@ -1 +1 @@ -
An explicit link Fourth Tiddler and a pretty link and a transclusion
An image
and a Stringy couple of Ç Ç "HTML Entity" and macro
5.0.0



\ No newline at end of file +
An explicit link Fourth Tiddler and a pretty link and a transclusion
A missing image
and a Stringy couple of Ç Ç "HTML Entity"



\ No newline at end of file diff --git a/test/wikitests/ThirdTiddler.txt b/test/wikitests/ThirdTiddler.txt index 1ffe635a0..8a4e9a1ff 100644 --- a/test/wikitests/ThirdTiddler.txt +++ b/test/wikitests/ThirdTiddler.txt @@ -1 +1 @@ -An explicit link Fourth Tiddler and a pretty link and a transclusion An image and a Stringy couple of Ç Ç "HTML Entity" and macro 5.0.0 \ No newline at end of file +An explicit link Fourth Tiddler and a pretty link and a transclusion A missing image and a Stringy couple of Ç Ç "HTML Entity" \ No newline at end of file