Hi Eric

Thank you for explaining things - and correcting my mistakes..

I'd like to be able to use this newtiddler call in the same template:
<<newTiddler label: [[create]] text:[[/%\n!$2\nterm:\n!$3\ndefinition:
\n!end %/]] tag:[[$1]] focus:title\>\>

How would I get the bracketed list of tags into the new tiddler macro?

Cheers Måns Mårtensson

On 13 Jun., 20:49, Eric Shulman <[email protected]> wrote:
> > This seems to work:
> > [[Memo2]]
> > <<forEachTiddler where 'tiddler.tags.containsAny(["$1"])'
>
> > and in another tiddler:
> > <<tiddler MeMo2 with: [[kicks","terms","basic]]>>
>
> You need to be very careful with tricks like this.  Correct use of
> quotes and square brackets are critical.  The reason this works is
> because:
>
> A) The doubled square-brackets surrounding the macro parameter are
> used to "quote" the value (so it is seen as one parameter.  The actual
> *value* of the parameter is:
>    kicks","terms","basic
> Note the lack of outer quotes.. this is important
>
> B) tiddler.tags.containsAny(...) accepts an *array* of values as
> input.  The code above uses
>    ...containsAny(["$1"])
> Note the surrounding SINGLE '[' and ']'.  These are the array
> delimiters, and the content inside the brackets is a *comma-separated
> list* of javascript values.
>
> C) Also note the doublequotes around $1... this is the tricky part:
> when the <<tiddler>> macro parameter is substituted into the code, the
> outermost doublequotes (from the code) are combined with the 'inner'
> quotes from the parameter value, and you get:
>    ...containsAny(["kicks","terms","basic"])
>
> which is a valid javascript array of text strings.
>
> A more reliable way to do this is to pass a simple space-separated
> parameter value (without the inner quotes and commas) and then use
> readBracketedList() in the code to turn it into an array:
>
> [[Memo2]]
> <<forEachTiddler where
> 'tiddler.tags.containsAny("$1".readBracketedList())'
>
> and in another tiddler:
> <<tiddler MeMo2 with: "kicks terms basic">>
>
> enjoy,
> -e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to