From 5a5c967a3943beb6a4fa513cb34d231e46304452 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 3 Jan 2020 10:40:11 +0000 Subject: [PATCH] Add support for $:/tags/Macro/View macros that are only visible within view templates --- core/ui/EditTemplate/Preview/output.tid | 1 + core/ui/ViewTemplate.tid | 1 + editions/tw5.com/tiddlers/concepts/Macros.tid | 4 ++-- .../systemtags/SystemTag_ $__tags_Macro_View.tid | 9 +++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 editions/tw5.com/tiddlers/systemtags/SystemTag_ $__tags_Macro_View.tid diff --git a/core/ui/EditTemplate/Preview/output.tid b/core/ui/EditTemplate/Preview/output.tid index fa330b8c0..985fae64d 100644 --- a/core/ui/EditTemplate/Preview/output.tid +++ b/core/ui/EditTemplate/Preview/output.tid @@ -2,6 +2,7 @@ title: $:/core/ui/EditTemplate/body/preview/output tags: $:/tags/EditPreview caption: {{$:/language/EditTemplate/Body/Preview/Type/Output}} +\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!has[draft.of]] <$set name="tv-tiddler-preview" value="yes"> <$transclude /> diff --git a/core/ui/ViewTemplate.tid b/core/ui/ViewTemplate.tid index 54765fbde..077fb79b8 100644 --- a/core/ui/ViewTemplate.tid +++ b/core/ui/ViewTemplate.tid @@ -3,6 +3,7 @@ title: $:/core/ui/ViewTemplate \define folded-state() $:/state/folded/$(currentTiddler)$ \end +\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!has[draft.of]] <$vars storyTiddler=<> tiddlerInfoState=<>>
> data-tags={{!!tags}} class={{{ tc-tiddler-frame tc-tiddler-view-frame [is[tiddler]then[tc-tiddler-exists]] [is[missing]!is[shadow]then[tc-tiddler-missing]] [is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [is[system]then[tc-tiddler-system]] [{!!class}] [tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}}><$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]]" variable="listItem"><$transclude tiddler=<>/>
diff --git a/editions/tw5.com/tiddlers/concepts/Macros.tid b/editions/tw5.com/tiddlers/concepts/Macros.tid index c7e824b76..239045d56 100644 --- a/editions/tw5.com/tiddlers/concepts/Macros.tid +++ b/editions/tw5.com/tiddlers/concepts/Macros.tid @@ -1,5 +1,5 @@ created: 20140211171341271 -modified: 20150228114909000 +modified: 20200103092706002 tags: Concepts Reference title: Macros type: text/vnd.tiddlywiki @@ -20,7 +20,7 @@ Within a snippet itself, the only markup detected is `$name$` (a placeholder for The <<.mlink dumpvariables>> macro lists all variables (including macros) that are available at that position in the widget tree. -An <<.wlink ImportVariablesWidget>> widget can be used to copy macro definitions to another branch of the [[widget tree|Widgets]]. ~TiddlyWiki uses this technique internally to implement global macros -- namely any macros defined in tiddlers with the <<.tag $:/tags/Macro>> tag. +An <<.wlink ImportVariablesWidget>> widget can be used to copy macro definitions to another branch of the [[widget tree|Widgets]]. ~TiddlyWiki uses this technique internally to implement global macros -- namely any macros defined in tiddlers with the <<.tag $:/tags/Macro>> tag. (The tag <<.tag $:/tags/Macro/View>> is used to define macros that should only be available within the main view template and the preview panel). For maximum flexibility, macros can also be <<.js-macro-link "written as JavaScript modules">>. diff --git a/editions/tw5.com/tiddlers/systemtags/SystemTag_ $__tags_Macro_View.tid b/editions/tw5.com/tiddlers/systemtags/SystemTag_ $__tags_Macro_View.tid new file mode 100644 index 000000000..81a6f9cae --- /dev/null +++ b/editions/tw5.com/tiddlers/systemtags/SystemTag_ $__tags_Macro_View.tid @@ -0,0 +1,9 @@ +caption: $:/tags/Macro +created: 20200103092530990 +description: marks global macros +modified: 20200103092606462 +tags: SystemTags +title: SystemTag: $:/tags/Macro/View +type: text/vnd.tiddlywiki + +The [[system tag|SystemTags]] `$:/tags/Macro/View` marks macros that are only made available within the main view templates and the preview panel. \ No newline at end of file