1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Add support for $:/tags/Macro/View macros that are only visible within view templates

This commit is contained in:
Jeremy Ruston 2020-01-03 10:40:11 +00:00
parent 136dbf1a60
commit 5a5c967a39
4 changed files with 13 additions and 2 deletions

View File

@ -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 />

View File

@ -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=<<currentTiddler>> tiddlerInfoState=<<qualify "$:/state/popup/tiddler-info">>><div data-tiddler-title=<<currentTiddler>> data-tags={{!!tags}} class={{{ tc-tiddler-frame tc-tiddler-view-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}}><$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]]" variable="listItem"><$transclude tiddler=<<listItem>>/></$list>
</div>
</$vars>

View File

@ -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">>.

View File

@ -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.