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 || {};
|
options = options || {};
|
||||||
var widgetNode = {
|
var widgetNode = {
|
||||||
type: "widget",
|
type: "widget",
|
||||||
children: []
|
children: [{
|
||||||
},
|
type: "importvariables",
|
||||||
currWidgetNode = widgetNode;
|
attributes: {
|
||||||
// Create set variable widgets for each variable
|
filter: {
|
||||||
$tw.utils.each(options.variables,function(value,name) {
|
name: "filter",
|
||||||
var setVariableWidget = {
|
type: "string",
|
||||||
type: "set",
|
value: "[all[shadows+tiddlers]tag[$:/tags/Global]!is[draft]]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isBlock: false,
|
||||||
|
children: []
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
currWidgetNode = widgetNode.children[0];
|
||||||
|
// Create let variable widget for variables
|
||||||
|
if($tw.utils.count(options.variables) > 0) {
|
||||||
|
var letVariableWidget = {
|
||||||
|
type: "let",
|
||||||
attributes: {
|
attributes: {
|
||||||
name: {type: "string", value: name},
|
|
||||||
value: {type: "string", value: value}
|
|
||||||
},
|
},
|
||||||
children: []
|
children: []
|
||||||
};
|
};
|
||||||
currWidgetNode.children = [setVariableWidget];
|
$tw.utils.each(options.variables,function(value,name) {
|
||||||
currWidgetNode = setVariableWidget;
|
letVariableWidget.attributes[name] = {
|
||||||
|
name: name,
|
||||||
|
type: "string",
|
||||||
|
value: "" + value
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
currWidgetNode.children = [letVariableWidget];
|
||||||
|
currWidgetNode = letVariableWidget;
|
||||||
|
}
|
||||||
// Add in the supplied parse tree nodes
|
// Add in the supplied parse tree nodes
|
||||||
currWidgetNode.children = parser ? parser.tree : [];
|
currWidgetNode.children = parser ? parser.tree : [];
|
||||||
// Create the widget
|
// 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;
|
return tiddlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWidgetNode(parseTreeNode,wiki) {
|
function createWidgetNode(parser,wiki) {
|
||||||
return new widget.widget(parseTreeNode,{
|
return wiki.makeWidget(parser);
|
||||||
wiki: wiki,
|
|
||||||
document: $tw.fakeDocument
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseText(text,wiki,options) {
|
function parseText(text,wiki,options) {
|
||||||
var parser = wiki.parseText("text/vnd.tiddlywiki",text,options);
|
return wiki.parseText("text/vnd.tiddlywiki",text,options);
|
||||||
return parser ? {type: "widget", children: parser.tree} : undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderWidgetNode(widgetNode) {
|
function renderWidgetNode(widgetNode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user