Skip to content

Commit 2cc88b6

Browse files
committed
WIP
1 parent 1376501 commit 2cc88b6

File tree

23 files changed

+186
-141
lines changed

23 files changed

+186
-141
lines changed

Cookbook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The basic page template looks something like this:
3535
<!DOCTYPE html>
3636
<html>
3737
<head>
38-
<link rel="stylesheet" type="text/css" href="$paste{path-to-root.in.sh,$path}/style.css">
38+
<link rel="stylesheet" type="text/css" href="$paste(path-to-root.in.sh,$path)/style.css">
3939
<title>$include{title.in.txt}</title>
4040
</head>
4141
<body>

Filtering.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change the syntax of `$include` to: `$include(command,arg,...){file}` (and similar for `$paste`). The semantics are that `file` is found and expanded, then the result is fed to `command arg...`'s stdin. If you omit the `{file}`, then you are just running a command and expanding/pasting its output.

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,21 @@ a file.
110110

111111
Nancy expands a template file as follows:
112112

113-
1. Scan the file for commands. Expand any arguments to the command, run
114-
each command, and replace the command by the result.
115-
2. Output the result.
113+
1. Scan the text for commands. Expand any arguments to the command, run each
114+
command, and replace the command by the result, eliding any final
115+
newline. (This elision may look tricky, but it almost always does what
116+
you want, and makes `$include` behave better in various contexts.)
117+
2. Output the resultant text.
116118

117119
A command takes the form `$COMMAND` or `$COMMAND{ARGUMENT, ...}`.
118120

119-
Nancy treats its input as 8-bit ASCII, but command names and other
120-
punctuation only use the 7-bit subset. This means that any text encoding
121-
that is a superset of 7-bit ASCII can be used, such as UTF-8.
122-
123121
### Built-in commands
124122

125123
Nancy recognises these commands:
126124

127125
* *`$include{FILE}`* Look up the given source file in the input tree (see
128126
below); read its contents, then expand them (that is, execute any commands
129-
it contains) and return the result, eliding any final newline. (This
130-
elision may look tricky, but it almost always does what you want, and
131-
makes $include behave better in various contexts.)
127+
it contains) and return the result.
132128
* *`$paste{FILE}`* Like `$include`, but does not expand its result before
133129
returning it.
134130
* *`$path`* Expands to the file currently being expanded, relative to the

README.nancy.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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

77
Nancy is a simple templating system that copies a file or directory, filling
88
in 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.
100100
2. 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

104108
Nancy treats its input as 8-bit ASCII, but command names and other
105109
punctuation only use the 7-bit subset. This means that any text encoding
@@ -152,27 +156,24 @@ worked example.
152156
### Running other programs
153157

154158
In 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

164169
2. 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

172173
For example, to insert the current date:
173174

174175
```
175-
\$paste{date,+%Y-%m-%d}
176+
\$paste(date,+%Y-%m-%d)
176177
```
177178

178179
See 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
188189
backslash 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

200200
Note that the filenames supplied to `cat` refer not to the input tree, but
201201
to the file system.

0 commit comments

Comments
 (0)