On Monday, October 28, 2013 7:36:27 AM UTC-7, Bruce Seely wrote:

> The follow-up question is how I can parametrize the macro invocation text?
> I'd like to be able to do the following, where the values "13456" and "My 
> title text" are supplied by variables:
> <<newTiddler label:'make foo'  title:'foo-*13456*: *My title text*' 
> text:'<<baz *13456*>>' >>
> I don't think assigning the variables will be difficult, but I can't see 
> how to include the first variable, "13456", into the text parameter.
> Can store.getTiddlerText(), accept an argument that gets substituted in 
> the included tiddler text?
> Or, can a value be included in the text with the evaluated parameters 
> approach?
>

You can use all sorts of clever javascript code within an evaluated 
parameter to assemble a value from a combination of literals and variables.

It all depends on how your input value is stored.  For simplicity, let's 
suppose you use the TWCore <<option txtSomeName>> syntax to enter an 
"option" value.  Then, in the eval param javascript, you can refer to: 
config.options.txtSomeName to retrieve the value you entered.

Thus, you could write:

<<newTiddler label:'make foo'
   title:{{'foo-'+config.options.txtSomeName+*'*: *My title text*'}}
   text:{{'<<baz *'+*config.options.txtSomeName*+'*>>'}} >>

HOWEVER... this is still problematic... because the eval params in the 
<<newTiddler>> macro are calculated when the macro is *rendered*... not 
when it is clicked on.  Thus, the param values that are used will not 
change if you enter a new value in the <<option txtSomeName>> input field. 
 Fortunately, I've already solved this problem!  Start by installing this 
plugin:
    http://www.TiddlyTools.com/#ClickifyPlugin

Then, add "clickify" to the start of your macro, like this:
<<clickify newTiddler label:'make foo'
   title:{{'foo-'+config.options.txtSomeName+*'*: *My title text*'}}
   text:{{'<<baz *'+*config.options.txtSomeName*+'*>>'}} >>

This causes the macro to recalculate the eval params each time the 
corresponding link (e.g., "new tiddler") is clicked, so that the params are 
always constructed usnig the current values of any input variables (e.g., 
config.options.txtSomeName).

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
   http://www.TiddlyTools.com/#Donations

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
   http://www.TiddlyTools.com/#Contact



-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to