22
33![ logo] ( logo/nancy-small.png ) _ logo by Silvia Polverini_
44
5- $paste{ /bin/sh,-c,PYTHONPATH=. python -m nancy --version | tail +2 | head -2 | sed -e 's/$/ /'}
5+ $paste( /bin/sh,-c,PYTHONPATH=. python -m nancy --version | tail +2 | head -2 | sed -e 's/$/ /')
66
77Nancy is a simple templating system that copies a file or directory, filling
88in templates as it goes. It has just one non-trivial construct:
@@ -35,7 +35,7 @@ $ pip install nancy
3535## Invocation
3636
3737```
38- $paste{ /bin/sh,-c,PYTHONPATH=. python -m nancy --help | sed -e 's/usage: nancy/nancy/'}
38+ $paste( /bin/sh,-c,PYTHONPATH=. python -m nancy --help | sed -e 's/usage: nancy/nancy/')
3939```
4040
4141## Operation <a name =" operation " ></a >
@@ -99,7 +99,11 @@ Nancy expands a template file as follows:
9999 each command, and replace the command by the result.
1001002 . Output the result.
101101
102- A command takes the form ` \$COMMAND ` or ` \$COMMAND{ARGUMENT, ...} ` .
102+ A command is written as its name prefixed with a dollar sign: ` \$COMMAND ` .
103+ Some commands take an argument, given in braces: ` \$COMMAND{ARGUMENT} ` .
104+ Finally, some commands also take an optional external command and arguments:
105+ ` \$COMMAND(EXTERNAL-COMMAND, ARGUMENT, …){ARGUMENT} ` ; the argument in braces
106+ is optional in this case.
103107
104108Nancy treats its input as 8-bit ASCII, but command names and other
105109punctuation only use the 7-bit subset. This means that any text encoding
@@ -152,27 +156,24 @@ worked example.
152156### Running other programs
153157
154158In addition to the rules given above, Nancy also allows ` \$include ` and
155- ` \$paste ` to take their input from programs. This can be useful in a variety
156- of ways: to insert the current date or time, to make a calculation, or to
157- convert a file to a different format.
159+ ` \$paste ` to run external programs, whose output becomes the result of the
160+ command. If an input is given, it is supplied to the program’s standard
161+ input. This can be useful in a variety of ways: to insert the current date
162+ or time, to make a calculation, or to convert a file to a different format.
158163
159- Nancy can run a program in two ways:
164+ Nancy looks for programs in two ways:
160165
161- 1 . If a file found by an ` \$include ` or ` \$paste ` command has the “execute”
162- permission, it is run .
166+ 1 . Using the same rules as for finding an ` \$include ` or ` \$paste ` input,
167+ Nancy looks for a file which has the “execute” permission .
163168
1641692 . If no file of the given name can be found using the rules in the previous
165170 section, Nancy looks for an executable file on the user’s ` PATH ` (the
166- list of directories specified by the ` PATH ` environment variable). If one
167- is found, it is run.
168-
169- In either case, arguments may be passed to the program: use
170- ` \$include{FILE,ARGUMENT_1,ARGUMENT_2,…} ` , or the equivalent for ` \$paste ` .
171+ list of directories specified by the ` PATH ` environment variable).
171172
172173For example, to insert the current date:
173174
174175```
175- \$paste{ date,+%Y-%m-%d}
176+ \$paste( date,+%Y-%m-%d)
176177```
177178
178179See the [ date example] ( Cookbook.md#date-example ) in the Cookbook for more
@@ -188,14 +189,13 @@ To prevent a comma from being interpreted as an argument separator, put a
188189backslash in front of it:
189190
190191```
191- \$include{ cat,I\, Robot.txt,3 Rules of Robotics.txt}
192+ \$include( cat,I\, Robot.txt,3 Rules of Robotics.txt)
192193```
193194
194- This will run the ` \$include ` command with the following arguments:
195+ This will run the ` cat ` command with the following arguments:
195196
196- 1 . ` cat `
197- 2 . ` I, Robot.txt `
198- 3 . ` 3 Rules of Robotics.txt `
197+ 1 . ` I, Robot.txt `
198+ 2 . ` 3 Rules of Robotics.txt `
199199
200200Note that the filenames supplied to ` cat ` refer not to the input tree, but
201201to the file system.
0 commit comments