diff --git a/core/modules/filters/unknown.js b/core/modules/filters/unknown.js index 21856766b..1cc5d16e2 100644 --- a/core/modules/filters/unknown.js +++ b/core/modules/filters/unknown.js @@ -21,7 +21,7 @@ Export our filter function */ exports["[unknown]"] = function(source,operator,options) { // Check for a user defined filter operator - if(operator.operator.charAt(0) === ".") { + if(operator.operator.indexOf(".") !== -1) { var variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(operator.operator); if(variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) { var list = options.widget.evaluateVariable(operator.operator,{params: operator.operands, source: source}); diff --git a/core/modules/parsers/wikiparser/rules/html.js b/core/modules/parsers/wikiparser/rules/html.js index 64469e3b2..4dbd6a07c 100644 --- a/core/modules/parsers/wikiparser/rules/html.js +++ b/core/modules/parsers/wikiparser/rules/html.js @@ -78,7 +78,7 @@ exports.parseTag = function(source,pos,options) { orderedAttributes: [] }; // Define our regexps - var reTagName = /([a-zA-Z0-9\-\$]+)/g; + var reTagName = /([a-zA-Z0-9\-\$\.]+)/g; // Skip whitespace pos = $tw.utils.skipWhiteSpace(source,pos); // Look for a less than sign @@ -138,7 +138,7 @@ exports.parseTag = function(source,pos,options) { exports.findNextTag = function(source,pos,options) { // A regexp for finding candidate HTML tags - var reLookahead = /<([a-zA-Z\-\$]+)/g; + var reLookahead = /<([a-zA-Z\-\$\.]+)/g; // Find the next candidate reLookahead.lastIndex = pos; var match = reLookahead.exec(source); diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index ecb8a430b..6f9a8e4e1 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -546,8 +546,8 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) { var variableDefinitionName = "$" + parseTreeNode.type; if(this.variables[variableDefinitionName]) { var isOverrideable = function() { - // Widget is overrideable if it has a double dollar user defined name, or if it is an existing JS widget and we're not in safe mode - return parseTreeNode.type.charAt(0) === "$" || (!!self.widgetClasses[parseTreeNode.type] && !$tw.safeMode); + // Widget is overrideable if its name contains a period, or if it is an existing JS widget and we're not in safe mode + return parseTreeNode.type.indexOf(".") !== -1 || (!!self.widgetClasses[parseTreeNode.type] && !$tw.safeMode); }; if(!parseTreeNode.isNotRemappable && isOverrideable()) { var variableInfo = this.getVariableInfo(variableDefinitionName,{allowSelfAssigned: true}); diff --git a/editions/test/tiddlers/tests/data/transclude/CustomWidget-ActionWidget.tid b/editions/test/tiddlers/tests/data/transclude/CustomWidget-ActionWidget.tid index 0be77a9a3..296aa6931 100644 --- a/editions/test/tiddlers/tests/data/transclude/CustomWidget-ActionWidget.tid +++ b/editions/test/tiddlers/tests/data/transclude/CustomWidget-ActionWidget.tid @@ -12,15 +12,15 @@ title: Output title: Actions \whitespace trim - -\widget $$action-mywidget(one:'Jaguar') + +\widget $action.mywidget(one:'Jaguar') \whitespace trim <$action-setfield $tiddler="Result" $field="text" $value=<>/> \end -<$$action-mywidget one="Dingo"> +<$action.mywidget one="Dingo"> Crocodile - + + title: ExpectedResult diff --git a/editions/test/tiddlers/tests/data/transclude/CustomWidget-Simple.tid b/editions/test/tiddlers/tests/data/transclude/CustomWidget-Simple.tid index 15d0c8d9e..ccb590d4f 100644 --- a/editions/test/tiddlers/tests/data/transclude/CustomWidget-Simple.tid +++ b/editions/test/tiddlers/tests/data/transclude/CustomWidget-Simple.tid @@ -12,21 +12,21 @@ title: Output title: TiddlerOne \whitespace trim - -\widget $$mywidget(one:'Jaguar') + +\widget $my.widget(one:'Jaguar') \whitespace trim <$text text=<>/> <$slot $name="ts-raw"> Whale \end -<$$mywidget one="Dingo"> +<$my.widget one="Dingo"> Crocodile - -<$$mywidget one="BumbleBee"> + +<$my.widget one="BumbleBee"> Squirrel - -<$$mywidget/> + +<$my.widget/> + title: ExpectedResult diff --git a/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted-Empty.tid b/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted-Empty.tid index efd1e7041..0ada5100b 100644 --- a/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted-Empty.tid +++ b/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted-Empty.tid @@ -6,13 +6,13 @@ tags: [[$:/tags/wiki-test-spec]] title: Output \whitespace trim -\widget $$mywidget() +\widget $my.widget() <$slot $name=ts-raw>the body is empty \end -#<$$mywidget/> -#<$$mywidget> -#<$$mywidget>the body is not empty +#<$my.widget/> +#<$my.widget> +#<$my.widget>the body is not empty + title: ExpectedResult diff --git a/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted.tid b/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted.tid index c10e84127..eb7d61756 100644 --- a/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted.tid +++ b/editions/test/tiddlers/tests/data/transclude/CustomWidget-Slotted.tid @@ -6,21 +6,21 @@ tags: [[$:/tags/wiki-test-spec]] title: Output \whitespace trim -\widget $$mywidget(one:'Jaguar') +\widget $my.widget(one:'Jaguar') \whitespace trim <$text text=<>/> <$slot $name="ts-stuff"> Whale \end -<$$mywidget one="Dingo"> +<$my.widget one="Dingo"> <$fill $name="ts-stuff"> Crocodile - -<$$mywidget one="BumbleBee"> + +<$my.widget one="BumbleBee"> Squirrel - + + title: ExpectedResult diff --git a/editions/test/tiddlers/tests/data/transclude/CustomWidget-VariableAttribute.tid b/editions/test/tiddlers/tests/data/transclude/CustomWidget-VariableAttribute.tid index 8ef700b41..e4e7dbaaf 100644 --- a/editions/test/tiddlers/tests/data/transclude/CustomWidget-VariableAttribute.tid +++ b/editions/test/tiddlers/tests/data/transclude/CustomWidget-VariableAttribute.tid @@ -12,17 +12,17 @@ title: Output title: TiddlerOne \whitespace trim - -\widget $$mywidget($variable:'Jaguar') + +\widget $my.widget($variable:'Jaguar') \whitespace trim <$text text=<<$variable>>/> <$slot $name="ts-raw"> Whale \end -<$$mywidget $variable="Dingo"> +<$my.widget $variable="Dingo"> Crocodile - + + title: ExpectedResult diff --git a/editions/tw5.com/tiddlers/functions/Functions.tid b/editions/tw5.com/tiddlers/functions/Functions.tid index 3b06dddc7..dadce73a1 100644 --- a/editions/tw5.com/tiddlers/functions/Functions.tid +++ b/editions/tw5.com/tiddlers/functions/Functions.tid @@ -21,7 +21,7 @@ Functions can be invoked in several ways: * Directly transclude functions with the syntax `<>` * Assign functions to widget attributes with the syntax `
>>` * Invoke functions via the [[function Operator]] with the syntax `[function[myfn],[value],...]` -* Directly invoke functions whose names start with a period as custom filter operators with the syntax `[.myfn[value]]` +* Directly invoke functions whose names contain a period as custom filter operators with the syntax `[my.fn[value]]` or `[.myfn[value]]` !! How Functions Work diff --git a/editions/tw5.com/tiddlers/variables/Variable Usage.tid b/editions/tw5.com/tiddlers/variables/Variable Usage.tid index 2166f206a..bc5f36443 100644 --- a/editions/tw5.com/tiddlers/variables/Variable Usage.tid +++ b/editions/tw5.com/tiddlers/variables/Variable Usage.tid @@ -150,5 +150,5 @@ Below is an example macro, procedure and function definition. All three forms o *''tiddler titles'' - tiddlers are uniquely identified by their title. The namespace for tiddler titles and variable names are completely separate. *''variables'' - \define, <<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget, \function all create variables. If the same name is used, then later define will overwrite earlier defined *''<<.op function>> filter operator parameter'' - only variables defined using \function can be called using the <<.olink function>> operator - *''filter operators'' - only the [[javascript defined filter operators|Filter Operators]] and variables defined using \function with name starting with a dot can be called + *''filter operators'' - only the [[javascript defined filter operators|Filter Operators]] and variables defined using \function with name containing a dot can be called *''widgets'' - variables defined using \widget can be invoked using `<$widget/>` syntax ONLY if the name starts a dollar sign (to override existing javascript defined widgets) or double dollar sign (to define [[custom widgets|Custom Widgets]]). Without the dollar sign prefix, defining variables using \widget is no different than using \procedure. diff --git a/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid b/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid index c220302cf..3d762bed2 100644 --- a/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid +++ b/editions/tw5.com/tiddlers/widgets/Custom Widgets.tid @@ -15,26 +15,21 @@ Custom widgets can also be used to override built-in JavaScript widgets to custo Custom widgets are usually defined with the [[Pragma: \widget]]: ``` -\widget $$my-widget(attribute:"Default value") +\widget $my.widget(attribute:"Default value") This is the widget, and the attribute is <>. \end ``` -The name of the widget must start with one or two dollar signs: - -* A ''single dollar sign'' is used to override existing core widgets -** for example, `$text` or `$codeblock` -* ''Double dollar signs'' are used to define a custom widget -** for example, `$$mywidget` or `$$acme-logger` +The name of the widget must start with a dollar sign. If it is a user defined widget that does not override an existing widget then it must include at least one period (dot) within the name (for example `$my.widget` or `$acme.logger`). !! Using Custom Widgets Custom widgets are called in the same way as ordinary built-in widgets: ``` -<$my-widget/> +<$my.widget/> -<$my-widget attribute="The parameter"/> +<$my.widget attribute="The parameter"/> ``` The attributes that are specified in the widget call are made available as parameter variables. @@ -45,18 +40,18 @@ Within the definition of a custom widget the content of the calling widget is av For example: -<>/> <$slot $name="ts-raw"> Whale \end -<$$mywidget one="Dingo"> +<$my.widget one="Dingo"> Crocodile - + -<$$mywidget/>""">> +<$my.widget/>""">> !! How Custom Widgets Work