Skip to main content

Pelican plugin for applying useful Jinja filters in theme templates

Project description

Build Status PyPI Version

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 pelican-jinja-filters

As Jinja Filters is a namespace plugin, it should automatically be loaded by Pelican. 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; specifically Friday, November 4, 2020.

  • breaking_spaces – replaces 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, 2020

Or with your own date format:

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

gives:

Article Published Nov 04, 2020

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

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

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

pelican-jinja-filters-2.0.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pelican_jinja_filters-2.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pelican-jinja-filters-2.0.0.tar.gz.

File metadata

  • Download URL: pelican-jinja-filters-2.0.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.8 Darwin/17.7.0

File hashes

Hashes for pelican-jinja-filters-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f4cef4f6d90408208baa03ebc26bf225d182d33a760da33fd1ca788df47ecc08
MD5 eb6adaf40b74f0e8f8e761fcb2f8a14f
BLAKE2b-256 749cd70d30367bce712ce77a90a5bbbe3905f80645cd6923d4ace08eed50e5ff

See more details on using hashes here.

File details

Details for the file pelican_jinja_filters-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pelican_jinja_filters-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a99832b4e6f47674bbae820d3c99969b9920dba1e2a9776f5478538ed2180f21
MD5 5ae56d9a1b001997613a663eba545e64
BLAKE2b-256 a10525eff413a32fc5a3eaa975cfcc92b23834a418fef34a17ba50cdfda5ea48

See more details on using hashes here.

Supported by

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