diff --git a/core/modules/widgets/macrocall.js b/core/modules/widgets/macrocall.js index 23522629b..2f527cc96 100644 --- a/core/modules/widgets/macrocall.js +++ b/core/modules/widgets/macrocall.js @@ -73,6 +73,8 @@ MacroCallWidget.prototype.execute = function() { attributes: attributes, children: parseTreeNodes }]; + } else if(this.renderOutput === "text/raw") { + parseTreeNodes = [{type: "text", text: text}]; } else { // Otherwise, we'll render the text var plainText = this.wiki.renderText("text/plain",this.parseType,text,{parentWidget: this}); diff --git a/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid b/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid index 35df8e059..5a993564f 100644 --- a/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/MacroCallWidget.tid @@ -1,23 +1,38 @@ -title: MacroCallWidget -created: 201310241419 -modified: 201310300837 -tags: Widgets caption: macrocall +created: 20131024141900000 +modified: 20200928102843275 +tags: Widgets +title: MacroCallWidget +type: text/vnd.tiddlywiki ! Introduction -The macro call widget provides an alternative syntax for invoking macros. The advantage of the widget form is that it allows macro parameters to be specified as widget attributes, thus allowing indirection and macro values to be set. +The macro call widget provides a more flexible alternative syntax for invoking macros compared to the usual `<>` syntax documented in [[Macros in WikiText]]. -For example, a macro called `italicise` that takes a single parameter called `text` can be invoked in any of these ways: +For example, a macro called `italicise` that takes a single parameter called `text` would usually be invoked like this: ``` <> <> +``` + +The same macro can be invoked using the macro call widget like this: + +``` <$macrocall $name="italicise" text="Text to be made into italics"/> <$macrocall $name="italicise" text={{Title of tiddler containing text to be italicised}}/> <$macrocall $name="italicise" text=<>/> ``` +The advantages of the widget formulation are: + +* Macro parameters are specified as widget attributes, thus allowing indirection via `{{title!!field}}`, `<>` or `{{{filter}}}` +* The output format can be chosen from several options: +** `text/html` wikifies the text of the macro +** `text/plain` wikifies the text of the macro and then extracts the plain text characters (ie. ignoring HTML tags) +** `text/raw` returns the plain text of the macro, without wikification + + You can see several examples of the macro call widget within the core: * Listing module information: [[$:/snippets/modules]] @@ -31,5 +46,5 @@ The content of the `<$macrocall>` widget is ignored. |!Attribute |!Description | |$name |Name of the macro to invoke | |$type |ContentType with which the macro text should be parsed (defaults to `text/vnd.tiddlywiki`) | -|$output |ContentType for the output rendering (defaults to `text/html`, can also be `text/plain`) | +|$output |ContentType for the output rendering (defaults to `text/html`, can also be `text/plain` or `text/raw`) | |//parameters// |Macro parameters specified as attributes |