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
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 withthe output from external tools. It also allows to filter partsof the document through an external filter.
Including output from a utility
The most basic usecase for xtpl is to simply include the output from autility into the document.Consider the following example document (readme.txt.xtpl):
The basic structure of the project looks like this:<<<<tree -d --charset=ASCII>>>>
When invoked like this:
xtpl < readme.txt.xtpl
we will get the following output:
The basic structure of the project looks like this:.|-- classes| |-- lang4j| `-- templates|-- dist|-- gen-src| |-- lang4j| `-- ws|-- lib|-- src| |-- doc| |-- generated| |-- java| |-- templates| `-- test|-- test-results|-- testclasses| `-- lang4j`-- testout `-- lang4j
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 thatprocess. Like the following example:
A sorted list of names:<<<<sortMichaelMarkPaulAndrew>>>>
Piping this through xtpl will yield:
A sorted list of names:AndrewMarkMichaelPaul
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 bydot:
An example graph rendered using dot:<img href="<<<<dot -Tpng >>> graph.pngdigraph g{ a -> b c -> b}>>>>">
Now this yields the following output:
An example graph rendered using dot:<img href="graph.png">
Also there is now a file called graph.png, so that when we look at the file with the browserwe will see the graph.