Coder Social home page Coder Social logo

xtpl's Introduction

% 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):

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 that process. Like the following example:

A sorted list of names:

<<<<
sort
Michael
Mark
Paul
Andrew
>>>>

Piping this through xtpl will yield:


A sorted list of names:

Andrew
Mark
Michael
Paul

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:

An example graph rendered using dot:

<img href="<<<<
dot -Tpng >>> graph.png
digraph 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 browser we will see the graph.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.