Skip to main content

A minimalist template ENGINE allowing users to define their own simple templating languages.

Project description

===
TIE
===

Template Illiterate Engine

.. image:: https://raw.github.com/raphigaziano/TIE/master/TIE.jpg
:alt: Twin Ion Engine of Awesomeness
:align: center
:scale: 50 %

.. contents::
:local:
:backlinks: top

What is TIE ?
-------------

The TIE library provides a set of classes and utilities to facilitate the
definition of very simple, personal template languages.

The library provides a basic substitution engine based on regular expressions,
which doesn't recognize any particular syntax by itself; it's up to the user to
provide it with his own tag patterns as well as their optional, custom
behaviour.

TIE also provides simple tools to ease the definition of those custom tags,
and aims to allow for easy customisation or extension (either by providing
callbacks or by subclassing the provided types).

Do I need it ?
--------------

Maybe. Maybe not.

If you need a full-fledged template engine,
with lots of features and good performances,
then TIE is probably not for you.
You'll be far better off using an already established template language -
`Quite a lot of them <http://wiki.python.org/moin/Templating>`_ are already
part of the python ecosystem and have more than proven themselves.
Trying to emulate one of those with TIE *might* be possible,
but will surely prove very cumbersome and inneficient.

On the other hand, TIE might still be overkill if your requirements are very
simple.
Python's batteries include a very nice and quite powerful string formatting syntax,
and also provides a Template class for slightly more complex operations.
Those built-in features might be more than sufficient for what you have in mind.
(See http://docs.python.org/2/library/string.html for more info on python's
string operations.)

TIE aims to step in when python's built-in tools might be enough for the job,
but become too unwieldy to handle the task in a straight-forward way.

Installation
------------

You can install TIE by simply using pip (this is the recomanded way):

::

pip install tie

If you must, you can also use easy_install:

::

easy_install tie

Alternativeley, you could also clone the project's repository and run the
setup script:

::

git clone https://github.com/raphigaziano/TIE
cd TIE/
python setup.py install

Getting Started
---------------

For most basic uses, rendering a template with TIE involves 3 simple steps:

- Register your tag patterns
- Wrap your template(s) text in (a) Template object(s)
- Pass your templates the data they need to render them

A naive exemple could look like this:

.. code-block:: python

>>> import tie
>>> # Register a tag pattern
>>> tie.tag.register("name")
>>> # Instanciate a Template object
>>> my_template = tie.Template("Hello, name!")
>>> # Render it!
>>> res = my_template(name="raphi")
>>> print(res)
Hello, raphi!
>>> res = my_template(name="Darth Vader, lord of the sith")
>>> print(res)
Hello, Darth Vader, lord of the sith!

Read the (still incomplete)
`Full documentation <https://tie.readthedocs.org/en/latest/index.html>`_
hosted on readthedocs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TIE-0.1.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

TIE-0.1.0.win32.exe (74.8 kB view details)

Uploaded Source

File details

Details for the file TIE-0.1.0.tar.gz.

File metadata

  • Download URL: TIE-0.1.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for TIE-0.1.0.tar.gz
Algorithm Hash digest
SHA256 390c2e706daed46fd50c134c6ef7ea01cad4ccb71091adbcfd7a4d2799a2f41c
MD5 cbca9d39dae281f9a4bed77f4fbd09f8
BLAKE2b-256 a7677b02312588da4e6e476ae11c00185643027ed130d3165fbf7a17f0fd74b1

See more details on using hashes here.

File details

Details for the file TIE-0.1.0.win32.exe.

File metadata

  • Download URL: TIE-0.1.0.win32.exe
  • Upload date:
  • Size: 74.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for TIE-0.1.0.win32.exe
Algorithm Hash digest
SHA256 3f5f7c2c6e46890f238292daa09060484d49b3f337771758dc32a4e7d0628636
MD5 6f6385470beda43981c777f257561afe
BLAKE2b-256 7f8acf4a5eeb1f15ae3d98005e0d3b9aeaaaea0aacc45a1d7a1aeea5014ade06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page