Metadata-Version: 2.1
Name: pelican-jinja-filters
Version: 2.0.0
Summary: Pelican plugin for applying useful Jinja filters in theme templates
Home-page: https://github.com/pelican-plugins/jinja-filters
License: MIT
Keywords: jinja2,templates,pelican,plugin
Author: William Minchin
Author-email: w_minchin@hotmail.com
Requires-Python: >=3.6,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Framework :: Pelican
Classifier: Framework :: Pelican :: Plugins
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: markdown
Requires-Dist: markdown (>=3.2.2,<4.0.0); extra == "markdown"
Requires-Dist: pelican (>=4.5,<5.0)
Requires-Dist: titlecase (>=1.1.1,<2.0.0)
Project-URL: Bug Tracker, https://github.com/pelican-plugins/jinja-filters/issues
Project-URL: Documentation, https://github.com/pelican-plugins/jinja-filters/blob/master/README.rst
Project-URL: Funding, https://donate.getpelican.com/
Project-URL: Repository, https://github.com/pelican-plugins/jinja-filters
Description-Content-Type: text/x-rst

=============
Jinja Filters
=============

|build| |pypi|

.. |build| image:: https://img.shields.io/github/workflow/status/pelican-plugins/jinja-filters/build
    :target: https://github.com/pelican-plugins/jinja-filters/actions
    :alt: Build Status

.. |pypi| image:: https://img.shields.io/pypi/v/pelican-jinja-filters.svg
    :target: https://pypi.python.org/pypi/pelican-jinja-filters
    :alt: PyPI Version

``Jinja Filters`` is a plugin for `Pelican <https://docs.getpelican.com/>`_,
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 <https://palletsprojects.com/p/jinja/>`_.


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.

.. code-block:: sh

  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
  <https://docs.python.org/3.8/library/datetime.html#strftime-and-strptime-behavior>`_
  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:

.. code-block:: html+jinja

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

gives::

    Article Published Friday, November 4, 2020

Or with your own date format:

.. code-block:: html+jinja

    <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:

.. code-block:: html+jinja

    <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.


.. |--| unicode:: U+2013   .. en dash

