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/
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)
Built Distribution
Close
Hashes for templatory-0.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74651ee91dc5cd6ce2902553f9fff48067a38e1e91ba52761c1ec8e8916deb83 |
|
MD5 | 2a8fd63b7a32e6ad51635c76eed39bba |
|
BLAKE2b-256 | 8ab514a0a96fd87e0f96a24a32d206650d754a353d0c6e43d6321a0040079620 |