mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-12 10:20:26 +00:00
Add support for $:/tags/Global
This commit is contained in:
parent
dec45f0fc3
commit
6f9f92fa69
@ -1075,22 +1075,38 @@ exports.makeWidget = function(parser,options) {
|
||||
options = options || {};
|
||||
var widgetNode = {
|
||||
type: "widget",
|
||||
children: []
|
||||
children: [{
|
||||
type: "importvariables",
|
||||
attributes: {
|
||||
filter: {
|
||||
name: "filter",
|
||||
type: "string",
|
||||
value: "[all[shadows+tiddlers]tag[$:/tags/Global]!is[draft]]"
|
||||
}
|
||||
},
|
||||
isBlock: false,
|
||||
children: []
|
||||
}]
|
||||
},
|
||||
currWidgetNode = widgetNode;
|
||||
// Create set variable widgets for each variable
|
||||
$tw.utils.each(options.variables,function(value,name) {
|
||||
var setVariableWidget = {
|
||||
type: "set",
|
||||
currWidgetNode = widgetNode.children[0];
|
||||
// Create let variable widget for variables
|
||||
if($tw.utils.count(options.variables) > 0) {
|
||||
var letVariableWidget = {
|
||||
type: "let",
|
||||
attributes: {
|
||||
name: {type: "string", value: name},
|
||||
value: {type: "string", value: value}
|
||||
},
|
||||
children: []
|
||||
};
|
||||
currWidgetNode.children = [setVariableWidget];
|
||||
currWidgetNode = setVariableWidget;
|
||||
});
|
||||
$tw.utils.each(options.variables,function(value,name) {
|
||||
letVariableWidget.attributes[name] = {
|
||||
name: name,
|
||||
type: "string",
|
||||
value: "" + value
|
||||
}
|
||||
});
|
||||
currWidgetNode.children = [letVariableWidget];
|
||||
currWidgetNode = letVariableWidget;
|
||||
}
|
||||
// Add in the supplied parse tree nodes
|
||||
currWidgetNode.children = parser ? parser.tree : [];
|
||||
// Create the widget
|
||||
|
19
editions/test/tiddlers/tests/data/globals/Simple.tid
Normal file
19
editions/test/tiddlers/tests/data/globals/Simple.tid
Normal file
@ -0,0 +1,19 @@
|
||||
title: Globals/Simple
|
||||
description: Global procedures
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
\whitespace trim
|
||||
|
||||
<<this-is-one>>
|
||||
+
|
||||
title: One
|
||||
tags: $:/tags/Global
|
||||
|
||||
\procedure this-is-one() ONE
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>ONE</p>
|
@ -65,16 +65,12 @@ describe("Wiki-based tests", function() {
|
||||
return tiddlers;
|
||||
}
|
||||
|
||||
function createWidgetNode(parseTreeNode,wiki) {
|
||||
return new widget.widget(parseTreeNode,{
|
||||
wiki: wiki,
|
||||
document: $tw.fakeDocument
|
||||
});
|
||||
function createWidgetNode(parser,wiki) {
|
||||
return wiki.makeWidget(parser);
|
||||
}
|
||||
|
||||
function parseText(text,wiki,options) {
|
||||
var parser = wiki.parseText("text/vnd.tiddlywiki",text,options);
|
||||
return parser ? {type: "widget", children: parser.tree} : undefined;
|
||||
return wiki.parseText("text/vnd.tiddlywiki",text,options);
|
||||
}
|
||||
|
||||
function renderWidgetNode(widgetNode) {
|
||||
|
Loading…
Reference in New Issue
Block a user