diff --git a/core/modules/widgets/parameters.js b/core/modules/widgets/parameters.js index ef62ef4b5..890e9862a 100644 --- a/core/modules/widgets/parameters.js +++ b/core/modules/widgets/parameters.js @@ -70,7 +70,7 @@ ParametersWidget.prototype.execute = function() { // Assign any metaparameters $tw.utils.each(pointer.getTransclusionMetaParameters(),function(getValue,name) { var variableName = self.getAttribute("$" + name); - if(variableName !== undefined) { + if(variableName) { self.setVariable(variableName,getValue(name)); } }); diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 205947c0c..684032eae 100755 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -330,11 +330,11 @@ Get one of the special parameters to be provided by the parameters widget TranscludeWidget.prototype.getTransclusionMetaParameters = function() { var self = this; return { - "parseAsInline": function() { - return self.parseAsInline ? "yes" : "no"; + "parseMode": function() { + return self.parseAsInline ? "inline" : "block"; }, "parseTreeNodes": function() { - return JSON.stringify(self.parseTreeNode); + return JSON.stringify(self.parseTreeNode.children || []); }, "slotFillParseTreeNodes": function() { return JSON.stringify(self.slotFillParseTrees); diff --git a/editions/test/tiddlers/tests/data/transclude/Parameterised-Mode.tid b/editions/test/tiddlers/tests/data/transclude/Parameterised-Mode.tid new file mode 100644 index 000000000..04f5bbb04 --- /dev/null +++ b/editions/test/tiddlers/tests/data/transclude/Parameterised-Mode.tid @@ -0,0 +1,29 @@ +title: Transclude/Parameterised/Mode +description: Parameterised transclusion using the $parseMode attribute +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\whitespace trim + +<$transclude $tiddler='TiddlerOne' one='Ferret'> + +This is a block + +$transclude> + +<$transclude $tiddler='TiddlerOne'> +This is inline +$transclude> ++ +title: TiddlerOne + +\whitespace trim +<$parameters $parseMode="@parseMode"> + <$text text=<<@parseMode>>/> +$parameters> ++ +title: ExpectedResult + +
block
inline
\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/transclude/Parameterised-ParseTreeNodes.tid b/editions/test/tiddlers/tests/data/transclude/Parameterised-ParseTreeNodes.tid new file mode 100644 index 000000000..916e2abfb --- /dev/null +++ b/editions/test/tiddlers/tests/data/transclude/Parameterised-ParseTreeNodes.tid @@ -0,0 +1,29 @@ +title: Transclude/Parameterised/ParseTreeNodes +description: Parameterised transclusion using the $parseTreeNodes attribute +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\whitespace trim + +<$transclude $tiddler='TiddlerOne' one='Ferret'> + +This is a block + +$transclude> + +<$transclude $tiddler='TiddlerOne'> +This is inline +$transclude> ++ +title: TiddlerOne + +\whitespace trim +<$parameters $parseTreeNodes="@parseTreeNodes"> + <$text text=<<@parseTreeNodes>>/> +$parameters> ++ +title: ExpectedResult + +[{"type":"element","tag":"p","children":[{"type":"text","text":"This is a block","start":68,"end":83}],"start":68,"end":83}]
[{"type":"text","text":"This is inline","start":136,"end":152}]
\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/transclude/Parameterised-SlotFillParseTreeNodes.tid b/editions/test/tiddlers/tests/data/transclude/Parameterised-SlotFillParseTreeNodes.tid new file mode 100644 index 000000000..679748375 --- /dev/null +++ b/editions/test/tiddlers/tests/data/transclude/Parameterised-SlotFillParseTreeNodes.tid @@ -0,0 +1,29 @@ +title: Transclude/Parameterised/SlotFillParseTreeNodes +description: Parameterised transclusion using the $slotFillParseTreeNodes attribute +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\whitespace trim + +<$transclude $tiddler='TiddlerOne' one='Ferret'> +<$fill $name="one">This is first$fill> +<$fill $name="two">But this is second$fill> +$transclude> + +<$transclude $tiddler='TiddlerOne'> +<$fill $name="one">This is first +<$fill $name="two">But this is second$fill>$fill> +$transclude> ++ +title: TiddlerOne + +\whitespace trim +<$parameters $slotFillParseTreeNodes="@slotFillParseTreeNodes"> + <$text text={{{ [<@slotFillParseTreeNodes>jsonindexes[]join[,]] }}}/> +$parameters> ++ +title: ExpectedResult + +one,ts-raw,two
one,ts-raw
\ No newline at end of file