mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-29 02:56:51 +00:00
Support global macros via the importvariables widget
The new importvariables widget imports macro/variable definitions from the specified tiddlers and makes them available to its children. Allows us to split PageMacros up into separate tiddlers. We still support loading macros from $:/core/ui/PageMacros to help people upgrading. Fixes #644 and #559
This commit is contained in:
32
editions/tw5.com/tiddlers/widgets/ImportVariablesWidget.tid
Normal file
32
editions/tw5.com/tiddlers/widgets/ImportVariablesWidget.tid
Normal file
@@ -0,0 +1,32 @@
|
||||
created: 20140612142500000
|
||||
modified: 20140612175900970
|
||||
tags: widget
|
||||
title: ImportVariablesWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
! Introduction
|
||||
|
||||
The ImportVariablesWidget imports macro and variable definitions from a list of other tiddlers and makes them available to its children. For example:
|
||||
|
||||
```
|
||||
<$importvariables filter="[tag[mySpecialMacros]]">
|
||||
All the macros defined in tiddlers with the tag "mySpecialMacros" are available here
|
||||
</$importvariables>
|
||||
```
|
||||
|
||||
! Attributes and Content
|
||||
|
||||
The content of the importvariables widget is the scope within which the imported variable definitions are available.
|
||||
|
||||
|!Attribute |!Description |
|
||||
|filter |[[Tiddler filter|TiddlerFilters]] defining the tiddlers from which macro definitions will be imported |
|
||||
|
||||
! Global Macros
|
||||
|
||||
So-called global macros are implemented within the main page template ([[$:/core/ui/PageTemplate]]) by wrapping the page content in the following importvariables widget:
|
||||
|
||||
```
|
||||
<$importvariables filter="[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]">
|
||||
...
|
||||
</$importvariables>
|
||||
```
|
||||
Reference in New Issue
Block a user