mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Add support for a transformFilter for prompts
This commit is contained in:
parent
b31e2cd0db
commit
e3714929f9
@ -146,7 +146,14 @@ Commander.prototype.stringifyToken = function(index,callback) {
|
||||
promptText: token.prompt || "Please enter a value",
|
||||
defaultResult: token["default"] || "",
|
||||
callback: function(err,userText) {
|
||||
callback(err,userText);
|
||||
if(err) {
|
||||
callback(err);
|
||||
} else {
|
||||
if(token.transformFilter) {
|
||||
userText = self.wiki.filterTiddlers(token.transformFilter,null,self.wiki.makeTiddlerIterator([userText]))[0] || "";
|
||||
}
|
||||
callback(null,userText);
|
||||
}
|
||||
},
|
||||
input: self.streams.input,
|
||||
output: self.streams.output,
|
||||
|
@ -30,7 +30,7 @@ Command tokens can be a simple string or <<.from-version "5.3.6">> a command tok
|
||||
|
||||
* ''filter'': the value of the first result of a filter expression specified in the ''text'' property of the command token object
|
||||
* ''wikify'': the result of wikifying a text string specified in the ''text'' property of the command token object
|
||||
* ''prompt'': the result of prompting the user for a string. The ''prompt'' property of the command token object specifies the textual prompt to be used. The optional ''default'' property specifies a string value to be used if the user presses enter in response to the prompt
|
||||
* ''prompt'': the result of prompting the user for a string. The ''prompt'' property of the command token object specifies the textual prompt to be used. The optional ''default'' property specifies a string value to be used if the user presses enter in response to the prompt. The optional ''transformFilter'' property specifies a filter to be applied to the user input to transform it into a command token. The string input by the user is available in the variable `user-input`
|
||||
|
||||
The EchoCommand is useful for debugging complex dynamic command tokens.
|
||||
|
||||
|
@ -39,7 +39,8 @@
|
||||
{
|
||||
"type": "prompt",
|
||||
"prompt": "Please enter some text and type enter",
|
||||
"default": "Nothing"
|
||||
"default": "Nothing",
|
||||
"transformFilter": "[addprefix[testing ]]"
|
||||
}
|
||||
],
|
||||
"index": [
|
||||
|
Loading…
Reference in New Issue
Block a user