Skip to main content

Takes a *context* and renders one or more Jinja *templates* with it.

Project description

# Templator

Takes a *context* and renders one or more [Jinja] *templates* with it. You can
build the context by manually setting keywords, loading data files or giving
content as markup files.

- Supports [Markdown] and [ReStructuredText] as input formats for markup files
- and [JSON] and [YAML] as formats for data files.


## Usage

usage: templator [--content <FILE>…] [--data <FILE>…] [--extra <KEY> <VALUE>]… [--css <FILE>…] [--js <FILE>…] [<TEMPLATE>]…

Builds a context and prints the render TEMPLATEs to `stdout`.

positional arguments:
FILE JINJA2 template(s) to use (default: simple HTML5
wrapper)

optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-v, --verbose show additional output
--debug [VERBOSE] show context and exit
-l, --list lists all special context variables for the default
template

Input:
Load data into the context.

-c FILE [FILE ...], --content FILE [FILE ...]
`content` for the context — MD or RST files get
rendered before usage
-d FILE [FILE ...], --data FILE [FILE ...]
add data from FILE (JSON / YAML) to the context
-e STRING STRING, --extra STRING STRING
add `key value` pair to the context

Output:
Pass the context to the template(s). If no template is set, a default HTML
5 template is used.

-C FILE [FILE ...], --css FILE [FILE ...]
include the content of each FILE in it's own `style`
tag
-J FILE [FILE ...], --javascript FILE [FILE ...]
include the content of each FILE in it's own `script`
tag
-M STRING, --merger STRING
join output of all templates with this STRING
--minimize minimize output (for HTML)


## Examples

$ templator -e content 'Hello World!' -e title 'Testy'
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Testy</title>
</head>
<body>Hello World!</body>
</html>

$ templator -e content 'Hello World!' -e title 'Testy' --minimize
<!doctype html>
<html> <head><meta charset=utf-8><meta name=viewport content="width=device-width, initial-scale=1.0"><title>Testy</title></head> <body>Hello World!</body> </html>

$ echo '*Hello*' > testytest.md; templator -c testytest.md
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body><p><em>Hello</em></p></body>
</html>


[jinja]: http://jinja.pocoo.org/
[markdown]: http://spec.commonmark.org/
[restructuredtext]: http://docutils.sourceforge.net/docs/user/rst/quickref.html
[json]: http://json.org/
[yaml]: http://yaml.org/

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

templatory-0.4.0.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

templatory-0.4.0-py2.py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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