You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`filters`| Array | Names of filters to apply to all pages in this target. |
190
-
|`image_subs`| Dictionary | Mapping of image paths to replacement paths that should be used when building this target. (Use this, for example, to provide absolute paths to images uploaded to a CDN or CMS.) |
191
-
| ... | (Various) | Arbitrary key-values to be inherited by all pages in this target. (You can use this for pre-processing or in templates.) The following field names cannot be used: `name`, `display_name`, `image_subs`, `filters`, and `pages`. |
|`filters`| Array | Names of filters to apply to all pages in this target. |
190
+
|`image_subs`| Dictionary | Mapping of image paths to replacement paths that should be used when building this target. (Use this, for example, to provide absolute paths to images uploaded to a CDN or CMS.) |
191
+
|`image_re_subs`| Dictionary | Same as `image_subs`, but the keys are regular expressions and the patterns can contain backreferences to matched subgroups (e.g. `\\1` for the first parenthetical group). |
192
+
| ... | (Various) | Arbitrary key-values to be inherited by all pages in this target. (You can use this for pre-processing or in templates.) The following field names cannot be used: `name`, `display_name`, `image_subs`, `filters`, and `pages`. |
192
193
193
194
### Pages
194
195
@@ -250,6 +251,43 @@ Dactyl pre-processes Markdown files by treating them as [Jinja][] Templates, so
250
251
|`pages`| The [array of page definitions](#pages) in the current target. |
251
252
|`currentpage`| The definition of the page currently being rendered. |
252
253
254
+
255
+
### Adding Variables from the Commandline
256
+
257
+
You can pass in a JSON or YAML-formatted list of variables using `--vars` commandline switch. Any such variables get added as fields of `target` and inherited by `currentpage` in any case where `currentpage` does not already have the same variable name set. For example:
258
+
259
+
```sh
260
+
$ cat md/vartest.md
261
+
Myvar is: '{{ target.myvar }}'
262
+
263
+
$ dactyl_build --vars '{"myvar":"foo"}'
264
+
rendering pages...
265
+
writing to file: out/index.html...
266
+
Preparing page vartest.md
267
+
reading markdown from file: vartest.md
268
+
... parsing markdown...
269
+
... modifying links for target: default
270
+
... re-rendering HTML from soup...
271
+
writing to file: out/test_vars.html...
272
+
done rendering
273
+
copying static pages...
274
+
275
+
$ cat out/test_vars.html | grep Myvar
276
+
<p>Myvar is: 'foo'</p></main>
277
+
```
278
+
279
+
If argument to `--vars` ends in `.yaml` or `.json`, Dactyl treats the argument as a filename and opens it as a YAML file. (YAML is a superset of JSON, so this works for JSON files.) Otherwise, Dactyl treats the argument as a YAML/JSON object directly. Be sure that the argument is quoted and escaped as necessary based on the commandline shell you use.
280
+
281
+
You cannot set the following reserved keys:
282
+
283
+
-`name`
284
+
-`display_name` (Instead, use the `--title` argument to set the display name of the target on the commandline.)
285
+
-`filters`
286
+
-`image_subs`
287
+
-`image_re_subs`
288
+
-`pages`
289
+
290
+
253
291
### Filters
254
292
255
293
Furthermore, Dactyl supports additional custom post-processing through the use of filters. Filters can operate on the markdown (after it's been pre-processed), on the raw HTML (after it's been parsed), or on a BeautifulSoup object representing the output HTML. Dactyl comes with several filters, which you can enable in your config file. Support for user-defined filters is planned but not yet implemented.
0 commit comments