mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-09 11:29:58 +00:00
04e91245cb
Now there is now longer a dummy DOM element corresponding to the macro itself. Instead, macros must create a single element child. This allows us to more easily fit Bootstrap's requirements for HTML layout (eg, that problem with links in navbars not being recognised). The refactoring isn't complete, there are still a few bugs to chase down
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
/*\
|
|
title: $:/core/modules/macros/include.js
|
|
type: application/javascript
|
|
module-type: macro
|
|
|
|
Include macro
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
exports.info = {
|
|
name: "include",
|
|
params: {
|
|
filter: {byPos: 0, type: "filter"},
|
|
as: {byPos: 1, type: "text"},
|
|
removePrefix: {byName: true, type: "text"}
|
|
}
|
|
};
|
|
|
|
exports.executeMacro = function() {
|
|
var as = this.params.as || "text/plain",
|
|
t;
|
|
if(this.hasParameter("filter")) {
|
|
var titles = this.wiki.filterTiddlers(this.params.filter),
|
|
result = [];
|
|
if(this.hasParameter("removePrefix")) {
|
|
for(t=0; t<titles.length; t++) {
|
|
var originalTiddler = this.wiki.getTiddler(titles[t]),
|
|
title = titles[t];
|
|
if(title.indexOf(this.params.removePrefix) === 0) {
|
|
title = title.substr(this.params.removePrefix.length);
|
|
var modifiedTiddler = new $tw.Tiddler(originalTiddler,{title: title});
|
|
result.push(this.wiki.serializeTiddler(modifiedTiddler,as));
|
|
}
|
|
}
|
|
} else {
|
|
for(t=0; t<titles.length; t++) {
|
|
result.push(this.wiki.serializeTiddler(titles[t],as));
|
|
}
|
|
}
|
|
return $tw.Tree.Element("pre",{},[
|
|
$tw.Tree.Text(result.join("\n"))
|
|
]);
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
})();
|