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
Rather than simply run, rather than read, a file found to be executable, add
new “external arguments”. Both `$paste` and `$include` can now have regular
and/or external arguments. When external arguments are provided, they
specify a program and command-line arguments to run. The program is looked
up as before, so it can be found via the include mechanism, or on PATH.
When an input is provided, feed it to the program on standard input.
As before, the command expands to the program’s standard output.
Last updated: $paste{python,-c,import datetime; print(datetime.now().strftime('%Y-%m-%d'))}
166
+
Last updated: $paste(python,-c,import datetime; print(datetime.now().strftime('%Y-%m-%d')))
167
167
```
168
168
169
169
This gives a result looking something like:
@@ -194,11 +194,11 @@ This can be done conveniently with environment variables, by invoking Nancy as f
194
194
env VARIABLE1=value1 VARIABLE2=value2 … nancy …
195
195
```
196
196
197
-
Then, you can use `$include{printenv,VARIABLE1}` (or the equivalent in Python or other languages) in the template files. [python-project-template](https://github.com/rrthomas/python-project-template) uses this technique to generate skeleton Python projects.
197
+
Then, you can use `$include(printenv,VARIABLE1)` (or the equivalent in Python or other languages) in the template files. [python-project-template](https://github.com/rrthomas/python-project-template) uses this technique to generate skeleton Python projects.
198
198
199
199
## Adding code examples and command output to Markdown
200
200
201
-
Source code examples can be added inline as normal in Markdown [code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks), but it’s often more convenient to include code directly from a source file. This can be done directly with `$paste`, or you can use the `cat` command to include a file that is not in the Nancy input tree: `$paste{cat,/path/to/source.js}`.
201
+
Source code examples can be added inline as normal in Markdown [code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks), but it’s often more convenient to include code directly from a source file. This can be done directly with `$paste`, or you can use the `cat` command to include a file that is not in the Nancy input tree: `$paste(cat,/path/to/source.js)`.
202
202
203
203
The output of commands can similarly be included in documents. The output of terminal commands may be better included in a code block, to preserve formatting that depends on a fixed-width font.
204
204
@@ -219,5 +219,5 @@ zip -r archive.zip .
219
219
Assuming it is called `make-zip.in.sh`, it can be used thus, from a file called `make-zip.in.nancy`:
The corresponding source files are laid out as follows. This may look a little confusing at first, but note the similarity to the HTML pages, and hold on for the explanation!
Note that there is only one menu fragment (the main menu is the same for every page), while each section has its own breadcrumb trail (`breadcrumb.in.html`), and each page has its own content (`main.in.html`).
46
46
47
-
Now consider how Nancy builds the page whose URL is `Places/Vladivostok/index.html`. Assume the source files are in the directory `source`. This page is built from `source/Places/Vladivostok/index.nancy.html`, whose contents is `$paste{cat,tests/test-files/cookbook-example-website-src/Places/Vladivostok/index.nancy.html}`. According to the rules given in the [Operation](README.md#operation) section of the manual, Nancy will look first for files in `source/Places/Vladivostok`, then in `source/places`, and finally in `source`. Hence, the actual list of files used to assemble the page is:
47
+
Now consider how Nancy builds the page whose URL is `Places/Vladivostok/index.html`. Assume the source files are in the directory `source`. This page is built from `source/Places/Vladivostok/index.nancy.html`, whose contents is `$paste(cat,tests/test-files/cookbook-example-website-src/Places/Vladivostok/index.nancy.html)`. According to the rules given in the [Operation](README.md#operation) section of the manual, Nancy will look first for files in `source/Places/Vladivostok`, then in `source/places`, and finally in `source`. Hence, the actual list of files used to assemble the page is:
## Dynamically naming output files and directories according
@@ -99,11 +99,11 @@ This can be done conveniently with environment variables, by invoking Nancy as f
99
99
env VARIABLE1=value1 VARIABLE2=value2 … nancy …
100
100
```
101
101
102
-
Then, you can use `\$include{printenv,VARIABLE1}` (or the equivalent in Python or other languages) in the template files. [python-project-template](https://github.com/rrthomas/python-project-template) uses this technique to generate skeleton Python projects.
102
+
Then, you can use `\$include(printenv,VARIABLE1)` (or the equivalent in Python or other languages) in the template files. [python-project-template](https://github.com/rrthomas/python-project-template) uses this technique to generate skeleton Python projects.
103
103
104
104
## Adding code examples and command output to Markdown
105
105
106
-
Source code examples can be added inline as normal in Markdown [code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks), but it’s often more convenient to include code directly from a source file. This can be done directly with `\$paste`, or you can use the `cat` command to include a file that is not in the Nancy input tree: `\$paste{cat,/path/to/source.js}`.
106
+
Source code examples can be added inline as normal in Markdown [code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks), but it’s often more convenient to include code directly from a source file. This can be done directly with `\$paste`, or you can use the `cat` command to include a file that is not in the Nancy input tree: `\$paste(cat,/path/to/source.js)`.
107
107
108
108
The output of commands can similarly be included in documents. The output of terminal commands may be better included in a code block, to preserve formatting that depends on a fixed-width font.
109
109
@@ -124,5 +124,5 @@ zip -r archive.zip .
124
124
Assuming it is called `make-zip.in.sh`, it can be used thus, from a file called `make-zip.in.nancy`:
0 commit comments