mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-20 19:29:43 +00:00
3825e2579f
* feat: new text substitution support, first pass * fix: use the widget method instead of evaluating a filter * revert to earlier implementation that emulates macro syntax * fix: capitalize comments * feat: add support for triple backticks for substituted attributes * docs: added docs for substitute operator * chore: more docs tweaks * docs: substituted attributes, refactored docs for widget attributes * docs: fixed typo * docs: more examples for substituted attributes * docs: updated prior documentation on concatenating text and variables * docs: documentation corrections * Update editions/tw5.com/tiddlers/filters/examples/substitute Operator (Examples).tid Co-authored-by: btheado <brian.theado@gmail.com> --------- Co-authored-by: btheado <brian.theado@gmail.com>
36 lines
756 B
JavaScript
36 lines
756 B
JavaScript
/*\
|
|
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;
|
|
};
|
|
|
|
})();
|
|
|