I want the user of my wiki to be able to enter some text and then make a tiddler with the text as title, and a specific tag by clicking a button of his choice. For instance, for quickly entering a thing-to-do or an idea or a grocery. This works if I hard-code the tags. But if I try to parametrise the procedure used, it does not work. Why not?
The new tiddler is created with the entered text for its title, and the ‘tiddlertype’ field is created with the right value. But it gets no tags, not even the default tag ‘DEFAULT’. All goes well if I hard-code the tagging in make-item (i.e. tags="TODO")
What goes wrong? How can I mend it?
Thanks Eric, it works! But I have no clue why the double quotes are necessary. I did not see anything about it in the docs about procedures or buttons. Did I miss something?
A string containing ActionWidgets to be triggered when the key combination is detected
The $button widget’s parameter values can be
strings (enclosed in quotes)
macro/procedure calls (enclosed in doubled angle brackets)
tiddler field references (enclosed in doubled curly brackets)
If the $actions parameter value is a macro – $actions=<<someprocedure ...>> (without quotes) --, then that procedure is processed as soon as the $button widget is rendered. Processing the procedure simply replaces the procedure reference with a string containing the procedure’s contents. Thus, when the $button widget is clicked the actions that are performed are no longer a procedure, so no parameter substitutions occur.
In contrast, by placing the $actions parameter within quotes, the procedure call is not processed at all until the $button is actually clicked upon, so the passed in taggy:'TODO' parameter processing is performed and the internal <<taggy>> variable is properly set and applied in the $action-createtiddler widget.
What is a use case for explicitly not typing quotes if the action parameter is a unparametrised procedure? If there is none, and because the button DOES work then, I think the docs should recommend always using quotes, to avoid confusion like mine.
The use of quotes is in some ways universal, so they are not documented with each item but only once. Fortunately they follow the same standards as in most programming languages, it you stop and think about it the ways they work is essential and perhaps even the only way quoting can work. So learning TiddlyWiki quoting rules is a useful personal learning you can apply elsewhere.