Skip to main content

Jinja Filters for Pelican.

Project description

Deprecation Notice: This plugins is now being maintained as part of the Pelican-Plugins organization on GitHub. The new code repo is at GitHub.com/pelican-plugins/jinja-filters. The new PyPI package is at pelican-jinja-filters (for your requirements.txt) and the new plugin name is pelican.plugins.jinja_filters (to update PLUGINS in your pelicanconf.py).

Old Readme

Jinja Filters is a plugin for Pelican, a static site generator written in Python.

Jinja Filters provides a selection of functions (called filters) for templates to use when building your website. They are packaged for Pelican, but may prove useful for other projects that make use of Jinja2.

Installation

The easiest way to install Jinja Filters is through the use of pip. This will also install the required dependencies (currently pelican and titlecase) automatically.

pip install minchin.pelican.jinja_filters

Then, in your pelicanconf.py file, add Jinja Filters to your list of plugins:

PLUGINS = [
            # ...
            'minchin.pelican.jinja_filters',
            # ...
          ]

And that’s it! The filters are now available for use in your templates.

Usage

At present, the plugin includes the following filters:

  • datetime – allows you to change to format displayed for a datetime object. Optionally supply a datetime format string to get a custom format.

  • article_date – a specialized version of datetime that returns datetimes as wanted for article dates; speciefically Friday, November 4, 2016.

  • breaking_spaces – replaceds non-breaking spaces (HTML code &nbsp) with normal spaces.

  • titlecase – Titlecases the supplied string

For example, within your theme templates, you might have code like:

<span class="published">
    Article Published {{ article.date | article_date }}
</span>

gives:

Article Published Friday, November 4, 2016

Or with your own dateformat:

<span class="published">
    Article Published {{ article.date | datetime('%b %d, %Y') }}
</span>

gives:

Article Published Nov 04, 2016

Fitlers can also be chained, or applied in sequence. For example to remove breaking spaces and then titlecase a catgory name, you might have code like:

<a href="{{ SITEURL }}/{{ article.category.url }}">
    {{ article.category | breaking_spaces | titlecase}}
</a>

Known Issues

  • the setup.py file for this project does not run on Python 2.7. However, wheels of this project are “universal” and so can be generated by Python 3 and subsequently installed by Python 2.7.

License

Jinja Filters is under the MIT License. See attached License.txt for full license text.

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

minchin.pelican.jinja_filters-1.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

minchin.pelican.jinja_filters-1.1.0-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file minchin.pelican.jinja_filters-1.1.0.tar.gz.

File metadata

  • Download URL: minchin.pelican.jinja_filters-1.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6

File hashes

Hashes for minchin.pelican.jinja_filters-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f62c555beeab2f9cca18d4afb24c2168e50e64da09be14bf8b019f857a65ac02
MD5 6d0020374fefff9b006f28cbb226ca77
BLAKE2b-256 ba23ae437fd3c63e203f50c2103cce75ae15215ddb0b07d9a7135355bfb4d57d

See more details on using hashes here.

File details

Details for the file minchin.pelican.jinja_filters-1.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: minchin.pelican.jinja_filters-1.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6

File hashes

Hashes for minchin.pelican.jinja_filters-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 84f7ebf805131f171dbe62fce938a4f6da31f0a2fdca2fc5ee56e58521f6bb80
MD5 a3f9b014fab3e8dfce1dd5c757b77f68
BLAKE2b-256 39b0b9c1744d6558c7c9e97c0092148bcb43b223b586b89434b858bebb68c2b1

See more details on using hashes here.

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