mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Extend render command to allow multiple variables to be passed
This commit is contained in:
parent
9af68297cd
commit
a38dc17300
@ -8,15 +8,15 @@ Optionally, the title of a template tiddler can be specified. In this case, inst
|
||||
A name and value for an additional variable may optionally also be specified.
|
||||
|
||||
```
|
||||
--render <tiddler-filter> [<filename-filter>] [<render-type>] [<template>] [<name>] [<value>]
|
||||
--render <tiddler-filter> [<filename-filter>] [<render-type>] [<template>] [ [<name>] [<value>] ]*
|
||||
```
|
||||
|
||||
* ''tiddler-filter'': A filter identifying the tiddler(s) to be rendered
|
||||
* ''filename-filter'': Optional filter transforming tiddler titles into pathnames. If omitted, defaults to `[is[tiddler]addsuffix[.html]]`, which uses the unchanged tiddler title as the filename
|
||||
* ''render-type'': Optional render type: `text/html` (the default) returns the full HTML text and `text/plain` just returns the text content (ie it ignores HTML tags and other unprintable material)
|
||||
* ''template'': Optional template through which each tiddler is rendered
|
||||
* ''name'': Name of optional variable
|
||||
* ''value'': Value of optional variable
|
||||
* ''name'': Name of optional variables
|
||||
* ''value'': Value of optional variables
|
||||
|
||||
By default, the filename is resolved relative to the `output` subdirectory of the edition directory. The `--output` command can be used to direct output to a different directory.
|
||||
|
||||
@ -26,6 +26,7 @@ Notes:
|
||||
* Any missing directories in the path to the filename are automatically created.
|
||||
* When referring to a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets : `--render "[[Motovun Jack.jpg]]"`
|
||||
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being rendered, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
||||
* Multiple ''name''/''value'' pairs can be used to pass more than one variable
|
||||
* The `--render` command is a more flexible replacement for both the `--rendertiddler` and `--rendertiddlers` commands, which are deprecated
|
||||
|
||||
Examples:
|
||||
|
@ -37,14 +37,14 @@ Command.prototype.execute = function() {
|
||||
filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]",
|
||||
type = this.params[2] || "text/html",
|
||||
template = this.params[3],
|
||||
varName = this.params[4],
|
||||
varValue = this.params[5],
|
||||
variableList = this.params.slice(4),
|
||||
tiddlers = wiki.filterTiddlers(tiddlerFilter);
|
||||
$tw.utils.each(tiddlers,function(title) {
|
||||
var parser = wiki.parseTiddler(template || title),
|
||||
variables = {currentTiddler: title};
|
||||
if(varName) {
|
||||
variables[varName] = varValue || "";
|
||||
while(variableList.length >= 2) {
|
||||
variables[variableList[0]] = variableList[1];
|
||||
variableList = variableList.slice(2);
|
||||
}
|
||||
var widgetNode = wiki.makeWidget(parser,{variables: variables}),
|
||||
container = $tw.fakeDocument.createElement("div");
|
||||
|
Loading…
Reference in New Issue
Block a user