You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tags/variable.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,7 +164,7 @@ There are two parts to making this work. First a variable is created that stores
164
164
Note: A Textpattern tag, used as an attribute (a parsed attribute), must be surrounded with single quotes.
165
165
{: .alert-block .information}
166
166
167
-
Alternatively, to avoid complicated quote escaping inside the `value` attribute, you can use the tag as a container:
167
+
Alternatively, to avoid complicated [quote escaping](/tags/learning/#attribute-value-escaping) inside the `value` attribute, you can use the tag as a container:
@@ -240,6 +240,35 @@ Using the above code in a page template would permit you to use example.org/arti
240
240
241
241
Other tags used: [article](/tags/article), [else](/tags/else), [if_variable](/tags/if_variable), [page_url](/tags/page_url).
242
242
243
+
### Example 8: Using default values
244
+
245
+
You may want to make up a variable that contains the value of some dynamic content and display a default value if that content is empty. Conceptually, this seems easy but you need to bear in mind that the primary purpose of the `<txp:variable>` when used with a `value` is to _store_ the content and when used without a `value` it will _display_ any stored content.
246
+
247
+
To use default values you must therefore only use them when you intend to display what is stored and **not** when you assign the value to the variable. Viz:
0 commit comments