You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 6, 2023. It is now read-only.
Right now the lambda function only retrieve the template code as an argument.
However, I started thinking that it would make some sense to pass in a reference to the "context" item as an argument as well, so that you could potentially cache the results of the function call by replacing the context on-the-fly.
This obviously doesn't always make sense, but I have some situations where I have some variables I want to do as a lambda because the lookup expense is costly and they're not always used. By passing in a reference to the context item, I could change the context to point to the rendered string (instead of the function.)
Does anyone else think it's worth adding?
Here's a little proof of concept showing the basic idea would work:
// function to show off lambdafunctioncacheTest(context,item){varresults=createUUID();// here we cache the results in the original context objectcontext[item]=results;returnresults;}// a sample context objectcontext={test=cacheTest};for(i=1;i<=10;i=i+1){// this logic is handled by the get() methodif(isCustomFunction(context.test)){x=context.test(context,"test");}else{x=context.test;}// show the resultswriteOutput("<div>#i# = #x#</div>");}