mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-27 14:48:19 +00:00
Fixes functions to use variables set by filter runs (#7906)
* fix: functions should use variables set by filter runs * refactor: code clean up * chore: added more tests
This commit is contained in:
parent
fb85e91f82
commit
aa4aeb187c
@ -153,7 +153,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
|
|||||||
} else if(variable.isFunctionDefinition) {
|
} else if(variable.isFunctionDefinition) {
|
||||||
// Function evaluations
|
// Function evaluations
|
||||||
params = self.resolveVariableParameters(variable.params,actualParams);
|
params = self.resolveVariableParameters(variable.params,actualParams);
|
||||||
var variables = Object.create(null);
|
var variables = options.variables || Object.create(null);
|
||||||
// Apply default parameter values
|
// Apply default parameter values
|
||||||
$tw.utils.each(variable.params,function(param,index) {
|
$tw.utils.each(variable.params,function(param,index) {
|
||||||
if(param["default"]) {
|
if(param["default"]) {
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
title: Functions/FunctionFilterrunVariables
|
||||||
|
description: Functions in filter runs that set variables
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Idiosyncrasy
|
||||||
|
caption: Idiosyncrasy Caption Field
|
||||||
|
|
||||||
|
+
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
\procedure demo-subfilter() [<currentTiddler>]
|
||||||
|
\function .demo-function() [<currentTiddler>]
|
||||||
|
|
||||||
|
<$let currentTiddler="Idiosyncrasy">
|
||||||
|
<$text text={{{ [<currentTiddler>get[caption]!is[blank]else<currentTiddler>] :map[subfilter<demo-subfilter>] }}}/>,
|
||||||
|
<$text text={{{ [<currentTiddler>get[caption]!is[blank]else<currentTiddler>] :map[.demo-function[]] }}}/>
|
||||||
|
</$let>
|
||||||
|
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>Idiosyncrasy Caption Field,Idiosyncrasy Caption Field</p>
|
@ -0,0 +1,20 @@
|
|||||||
|
title: Functions/FunctionFilterrunVariables2
|
||||||
|
description: Functions in filter runs that set variables
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Apple
|
||||||
|
cost: 5
|
||||||
|
|
||||||
|
+
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
\function .doublecost() [<currentTiddler>get[cost]multiply[2]]
|
||||||
|
|
||||||
|
<$text text={{{ [[Apple]] :map[.doublecost[]] }}}/>
|
||||||
|
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
10
|
Loading…
Reference in New Issue
Block a user