-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.md.xtpl
93 lines (64 loc) · 1.89 KB
/
README.md.xtpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
% xtpl(1) templating utitiliy
% Felix Leipold
% May 2012
Description
===========
xtpl is a templating mechnism in the spirit of unix.
It was developed to help with document preparation,
but could also be used in other circumstances,
where text needs to be enriched with output from other utilities.
xtpl takes a template text and substitutes special expressions with
the output from external tools. It also allows to filter parts
of the document through an external filter.
Including output from a utility
===============================
The most basic usecase for xtpl is to simply include the output from a
utility into the document.
Consider the following example document (`readme.txt.xtpl`):
~~~~~ {.tpl}
<<<<
cat examples/output_from_utility.xtpl
>>>>
~~~~~
When invoked like this:
~~~~ {.bash}
xtpl < readme.txt.xtpl
~~~~
we will get the following output:
~~~~ {.tpl}
<<<<
./xtpl < examples/output_from_utility.xtpl
>>>>
~~~~
Filtering parts of the document
===============================
Now we do not only want to get the output from an external utility, we also want to pipe input into that
process. Like the following example:
~~~~ {.tpl}
<<<<
cat examples/filtering.xtpl
>>>>
~~~~
Piping this through xtpl will yield:
~~~~~ {.tpl}
<<<<
./xtpl < examples/filtering.xtpl
>>>>
~~~~~
Redirecting the output of a utility into a separate file - e.g. Images
======================================================================
Sometimes we also might want to include only a link to a resource into our text.
A classical example would be a graph generated by _dot_:
~~~~~~ {.example}
<<<<
cat examples/redirecting_utility_output_to_file.xtpl
>>>>
~~~~~~~
Now this yields the following output:
~~~~~~ {.html}
<<<<
./xtpl < examples/redirecting_utility_output_to_file.xtpl
>>>>
~~~~~~
Also there is now a file called graph.png, so that when we look at the file with the browser
we will see the graph.