I would like to give a mini-template for the text field in <$action-send-message $message="tm-new-tiddler" ...> I would like my new-question button to default the text to this:
''Question'':
<!-- when ready -->
''Answer'':
<!-- remove these comments -->
I tried this:
<$action-sendmessage $message="tm-new-tiddler"
title="New Question"
tags="[[Question]]"
text="''Question:''\n\n\n<!-- when ready -->\n\n''Answer:''\n\n<!-- remove these comments -->"
answered="no"
for=""/>
\end
But the backslash characters appear literally in the text. Another added level of backslashes simply appear there as well. Is there a simple way to handle this?
triple quotes as ^^ above """ allow for a surprising amount of coding within them, but the best result I’ve had with tm-new-tiddler text is to just straight transclude a tiddler as the attribute (eg text={{QuestionCommented}}).
It frees up a lot of editing restrictions, and you can dig yourself deeper transclusions in those too.
If you want to avoid using either tripled double-quotes or a separate tiddler, you could also achieve your desired result by using a macro to define the target tiddler text, like this:
Note that when a macro is used as a widget param value, it is NOT parsed (“wikified”). Thus, in the above code example, the contents of <<newQuestionText>> are used exactly as defined, with all the whitespace and HTML comments intact.
Looking at the stringify operator it will convert line feeds to \n so if we had a destringify convert \n to a newline, we could easily define a function or even add to the output of a filter made into a string with join any of these characters. I have found the charcode operator useful sometimes but you need a look up table.
I expect someone with javascript skills could clone the stringify and reverse its function.
The new tiddler is not automatically displayed in the story river
Without fully understanding the implications of the very next line:
The title of the new tiddler is made available for subsequent operations
I wanted to use the $basetitle here, so I kept looking back to this, and kept stopping over this issue. But, as described in Example 5, this allows me to create the widget and then immediately open it for editing in the river.
Thank you very much for the pointer!
Yes, from experience in many languages with C-style syntax (including JS) I simply assumed that the string would already be interpreted that way. The backslash is simply how important control characters are embedded in strings. You see it, for instance, in JSON, which escapes any embedded double quote marks with a backslash.