1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-18 03:19:55 +00:00
TiddlyWiki5/editions/test/tiddlers/tests/data/globals/CustomWidget.tid
jeremy@jermolene.com f636349007 Introduce true global variables
The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists.

This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro.

In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro
2022-05-28 12:23:50 +01:00

22 lines
426 B
Plaintext

title: Globals/CustomWidget
description: Global shadow variable defining a custom widget
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$$mywidget foo="Mahogany">
Sycamore!
</$$mywidget>
+
title: $:/global/$$mywidget
is-widget: yes
parameters: (foo:"bar")
Koala! <$text text=<<foo>>/>, <$slot $name="ts-body"/>
+
title: ExpectedResult
<p>Koala! Mahogany, Sycamore!</p>