Add a tag made of multiple words

Hello everyone,

In a tiddler, I need a button that create a new tiddler from a selected template and add some fields values as tags. (see my button’s code at the end of the post)

My problem is that three of these “tags” can be made of multiple words.

my current code pass each word of a field as a tag. For example, if the user set the field “scale” to “European Union”, it add the tags “European” and “Union” instead of the tag “European Union”.
Is there anything I could change to have each field as one single tag, no matter the number of words in the field ?

\define cardTags() [[$(tag1)$]] $(tag2)$ $(tag3)$ $(tag4)$

<$button>
<$vars tag1={{!!Scale}} tag2={{!!Subject}} tag3={{!!Counter}} tag4={{!!Template}}>
<$action-createtiddler $basetitle={{!!Name}} $template={{!!Template}} tags=<<cardTags>>> 
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
Create a new {{filtre template base!!Template}} named {{filtre template base!!Name}}
</$vars>
</$button>

The solution you posted seems to work fine. Perhaps you want a solution that works universally?

This solution uses the format:titlelist operator to apply brackets to the string elements only when they are needed:

<$button>
<$vars tag1={{!!Scale}} tag2={{!!Subject}} tag3={{!!Counter}} tag4={{!!Template}}>
<$action-createtiddler $basetitle={{!!Name}} $template={{!!Template}} tags={{{[<tag1>][<tag2>][<tag3>][<tag4>]+[format:titlelist[]]+[join[ ]]}}} > 
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
Create a new {{filtre template base!!Template}} named {{filtre template base!!Name}}
</$vars>
</$button>
2 Likes

Thank you for your answer, I’ll give it a go.

But, no my code wasn’t working, but in fact it was my fault.
I had worked from an example found on the web and I haddn’t understood that the “[[ ]]” in the define function were here to make tiddlywiki consider their content as a single string, and not multiple ones. I realized it, added brackets where needed, and it solved the problem.