1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-07 20:44:23 +00:00
TiddlyWiki5/core/modules/filters/substitute.js

36 lines
756 B
JavaScript
Raw Normal View History

/*\
title: $:/core/modules/filters/substitute.js
type: application/javascript
module-type: filteroperator
Filter operator for substituting variables and embedded filter expressions with their corresponding values
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.substitute = function(source,operator,options) {
var results = [],
operands = [];
$tw.utils.each(operator.operands,function(operand,index){
operands.push({
name: (index + 1).toString(),
value: operand
});
});
source(function(tiddler,title) {
if(title) {
results.push(options.wiki.getSubstitutedText(title,options.widget,{substitutions:operands}));
}
});
return results;
};
})();