This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Simple templating program to generate plain text (like config files) from name-value pairs.

Lets you create text files from templates in a versatile way. It’s designed with easy operation from the command line or scripts, Makefiles, etc. in mind. You can make use of several third party templating engines like mako or empy as well as simple built-in ones.

Installation

from a git repository into a virtualenv

This is a good approach if you work on the repository and want to test the changes.

Install eztemplate

$ git clone https://github.com/blubberdiblub/eztemplate.git
$ cd eztemplate                    # change into the cloned repository
$ virtualenv venv                  # create a new environment in a subdirectory
$ . venv/bin/activate              # switch to virtualenv (important)
$ pip install .                    # just specify the directory to install from
$ eztemplate --version             # check if the correct version was installed

Upgrade eztemplate

$ git pull                         # pull latest commits from remote repository
$ . venv/bin/activate              # switch to virtualenv (if not there already)
$ pip install --upgrade --force-reinstall . # force upgrade eztemplate
$ eztemplate --version             # check if the correct version was installed

from PyPI as system command

Install eztemplate

$ pip install eztemplate           # install eztemplate from PyPI
$ eztemplate --version             # check if the correct version was installed

Upgrade eztemplate

$ pip install --upgrade eztemplate # upgrade eztemplate from PyPI
$ eztemplate --version             # check if the corrent version was installed

Usage

Getting quick help

Use the help option:

$ eztemplate --help

You can also call the package explictly with Python (and thereby choose which Python installation to use):

$ python -m eztemplate --help

Running without arguments

When you run eztemplate without arguments, it will expect a template on standard input, possibly waiting forever:

$ eztemplate
Hello, world!
<Ctrl-D>
Hello, world!
$

On __*ix__ terminals you can manually cause an end of file by pressing Ctrl-D.

Quick demonstration

You can check that substitution is working by piping a template into the program and specifying a name-value pair (make sure to protect the string with single quotes, otherwise the shell believes you want to substitute a shell variable, replacing it by an empty string):

$ echo 'Hello, $entity.' | eztemplate entity=world
Hello, world.
$

When you’re calling eztemplate from a script or similar - i. e. non-interactively - you should specify everything as explicitly as possible (in particular all input files or stdin as well as name-value pairs) and refrain from using positional arguments. Everything can be specified using options, which avoids ambiguities:

$ echo 'Hello, $entity.' | eztemplate --stdin --arg entity=world
Hello, world.
$

Templating engines

eztemplate supports several templating engines. You select the one you want to use with the -e or --engine option. Specifying help instead of a name will list all currently available engines:

$ eztemplate -e help
Available templating engines:
  empy             -  Empy templating engine.
  mako             -  Mako templating engine.
  string.Template  -  String.Template engine.
$

Engines missing the required packages, modules or libraries will not be displayed. For instance to be able to use the mako or the empy engine, you need to have the respective python packages installed and working.

However, eztemplate comes with simple built-in engines which are available at all times. The string.Template engine is the default when you don’t explicitly specify one.

string.Template engine

This engine is named after the string.Template class in the Python standard library. It substitutes identifiers beginning with a dollar sign. To resolve ambiguities, you can also enclose the identifier in curly braces. It’s similar to shell variable subsitution minus the more sophisticated features. It suffices for simple cases where you just need to insert some values into a text:

$ eztemplate --stdin \
>   --arg user="$( getent passwd "$USER" | cut -d: -f5 | cut -d, -f1 )" \
>   --arg food=cake --arg vendor=cafeteria --arg price="$RANDOM" \
>   <<\EOF
> Hello, $user.
>
> If you're hungry, get some ${food}s from the $vendor.
> They're only $$$price per piece.
> EOF
Hello, Niels Boehm.

If you're hungry, get some cakes from the cafeteria.
They're only $29993 per piece.
$
Release History

Release History

0.3.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
eztemplate-0.3.0.linux-x86_64.tar.gz (19.6 kB) Copy SHA256 Checksum SHA256 Source Feb 29, 2016
eztemplate-0.3.0-py2-none-any.whl (44.6 kB) Copy SHA256 Checksum SHA256 py2 Wheel Feb 29, 2016
eztemplate-0.3.0-py3-none-any.whl (44.6 kB) Copy SHA256 Checksum SHA256 py3 Wheel Feb 29, 2016
eztemplate-0.3.0.tar.gz (15.4 kB) Copy SHA256 Checksum SHA256 Source Feb 29, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting