Jinja2 support for Pydgeot.
Project description
# Jinja2 Support for Pydgeot
Add support for [Jinja2](https://github.com/mitsuhiko/jinja2) templates to
[Pydgeot](http://www.github.com/broiledmeat/pydgeot). Any changes to extended or included templates will propagate
regeneration to the file that used those templates. Templates may set context variables that are accessible from
other templates, which will also affect the regeneration.
### Features
- Standard [Jinja2](https://github.com/mitsuhiko/jinja2) templating.
- Globally available context variables.
- Regenerate files dependent on other templates or context variables.
### Requirements
- Python 3.*
- [Pydgeot](http://www.github.com/broiledmeat/pydgeot)
- [Jinja2](https://github.com/mitsuhiko/jinja2)
### Installation
Via pip:
```bash
pip install pydgeot_jinja
```
Or via source:
```bash
git clone https://github.com/broiledmeat/pydgeot_jinja.git pydgeot_jinja
cd pydgeot_jinja
python setup.py install
```
### Configuration
Add `jinja` to your pydgeot.conf `plugins` list to enable the plugin. Then add `jinja` to the `processors` list in
pydgeot.conf, or nested .pydgeot.conf's, to use the file processor. Options are, also, placed under a `jinja` key.
- `source_ext` Extension of source files to build. _Default: .html_
- `build_ext` Extension of built files. _Default: .html_
```json
{
"plugins": ["jinja"],
"processors": ["jinja"],
"jinja" {
"source_ext": ".jinja"
}
}
```
### Usage
The Jinja2 plugin will process any `.html` (or `source_ext` extension specified in pydgeot.conf) file as a Jinja2
template.
A page may be marked as template only by setting the `template_only` variable to `True`. This will cause the file to not
be generated, but any changes will still cause dependent files to be generated.
#### Context Variables
Setting a context variable makes it available to the file it was created in, and to any other template file.
`{% setcontext name="value" }%`
Context variables can be accessed in the setting file (or extended and included files,) in the same way as if it had
been created with the standard Jinja `set`.
Context variables may be created with the same names across multiple sources, so global access is done iteratively.
`getcontexts(name, "value")` will retrieve a list of files that have set a context variable matching the name and value.
The value may be a [glob pattern](https://github.com/broiledmeat/pydgeot#glob-patterns).
For example, `{% for page in getcontexts("fullname", "test.*") %}` would find any file with context variables named
"fullname" with values starting with "test.", then grab all of that files context variables and set them as properties
of `page`.
Add support for [Jinja2](https://github.com/mitsuhiko/jinja2) templates to
[Pydgeot](http://www.github.com/broiledmeat/pydgeot). Any changes to extended or included templates will propagate
regeneration to the file that used those templates. Templates may set context variables that are accessible from
other templates, which will also affect the regeneration.
### Features
- Standard [Jinja2](https://github.com/mitsuhiko/jinja2) templating.
- Globally available context variables.
- Regenerate files dependent on other templates or context variables.
### Requirements
- Python 3.*
- [Pydgeot](http://www.github.com/broiledmeat/pydgeot)
- [Jinja2](https://github.com/mitsuhiko/jinja2)
### Installation
Via pip:
```bash
pip install pydgeot_jinja
```
Or via source:
```bash
git clone https://github.com/broiledmeat/pydgeot_jinja.git pydgeot_jinja
cd pydgeot_jinja
python setup.py install
```
### Configuration
Add `jinja` to your pydgeot.conf `plugins` list to enable the plugin. Then add `jinja` to the `processors` list in
pydgeot.conf, or nested .pydgeot.conf's, to use the file processor. Options are, also, placed under a `jinja` key.
- `source_ext` Extension of source files to build. _Default: .html_
- `build_ext` Extension of built files. _Default: .html_
```json
{
"plugins": ["jinja"],
"processors": ["jinja"],
"jinja" {
"source_ext": ".jinja"
}
}
```
### Usage
The Jinja2 plugin will process any `.html` (or `source_ext` extension specified in pydgeot.conf) file as a Jinja2
template.
A page may be marked as template only by setting the `template_only` variable to `True`. This will cause the file to not
be generated, but any changes will still cause dependent files to be generated.
#### Context Variables
Setting a context variable makes it available to the file it was created in, and to any other template file.
`{% setcontext name="value" }%`
Context variables can be accessed in the setting file (or extended and included files,) in the same way as if it had
been created with the standard Jinja `set`.
Context variables may be created with the same names across multiple sources, so global access is done iteratively.
`getcontexts(name, "value")` will retrieve a list of files that have set a context variable matching the name and value.
The value may be a [glob pattern](https://github.com/broiledmeat/pydgeot#glob-patterns).
For example, `{% for page in getcontexts("fullname", "test.*") %}` would find any file with context variables named
"fullname" with values starting with "test.", then grab all of that files context variables and set them as properties
of `page`.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydgeot_jinja-0.5.tar.gz
(4.6 kB
view details)
File details
Details for the file pydgeot_jinja-0.5.tar.gz
.
File metadata
- Download URL: pydgeot_jinja-0.5.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b47d7e2436d1f4aacbcffc699d487d850d90f361e923ab6d07d101502fce8e18 |
|
MD5 | 22a6a9d46fdf8469c2bd0830a24a7c0d |
|
BLAKE2b-256 | 1e03fbeea95c47c387c18d3bd852e45675b3cb01f79a1c3530e217c1cde1afae |