Skip to content

Commit

Permalink
Relax the restriction on the let widget being unable to create variab…
Browse files Browse the repository at this point in the history
…les starting with a dollar
  • Loading branch information
Jermolene committed Oct 1, 2022
1 parent 81e4745 commit 1df4c29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 3 additions & 5 deletions core/modules/widgets/let.js
Expand Up @@ -51,11 +51,9 @@ LetWidget.prototype.computeAttributes = function() {
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) {
var value = self.computeAttribute(attribute),
name = attribute.name;
if(name.charAt(0) !== "$") {
// Now that it's prepped, we're allowed to look this variable up
// when defining later variables
self.currentValueFor[name] = value;
}
// Now that it's prepped, we're allowed to look this variable up
// when defining later variables
self.currentValueFor[name] = value;
});
// Run through again, setting variables and looking for differences
$tw.utils.each(this.currentValueFor,function(value,name) {
Expand Down
5 changes: 4 additions & 1 deletion editions/tw5.com/tiddlers/widgets/LetWidget.tid
@@ -1,5 +1,6 @@
title: LetWidget
created: 20211028115900000
modified: 20221001094658854
tags: Widgets
caption: let

Expand All @@ -12,10 +13,12 @@ caption: let
The content of the <<.wid let>> widget is the scope for the value assigned to the variable.

|!Attribute |!Description |
|//{attributes not starting with $}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable |
|//{attributes}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable |

Attributes are evaluated in the order they are written. Attributes with the same name are allowed. Each time a duplicate attribute is encountered, it will replace the existing value set by the earlier duplicate.

<<.note """<<.from-version "5.2.4">> There is no longer any restriction on using variable names that start with the $ character.""">>

! Examples

Consider a case where you need to set multiple variables, where some depend on the evaluation of others.
Expand Down

0 comments on commit 1df4c29

Please sign in to comment.