semvec/pypi-packages huggingface dataset:
django-templates-macros 0.3
Add macros to your django templates
License: MIT

|PyPI Version|

django-templates-macros
=======================

Add macros to your django templates

------
Origin
------

The original code of this app is taken from https://djangosnippets.org/snippets/2892/ by MattP.

This snippets cites::

    Based on snippet by
        Michal Ludvig <michal@logix.cz> http://www.logix.cz/michal
        http://djangosnippets.org/snippets/363/

    Extended for args and kwargs into templatetags/kwacro.py by
        Skylar Saveland <michal@logix.cz> http://skyl.org
        https://gist.github.com/skyl/1715202

    Modified to support rendering into context by matt@peloquin.com


-----
Where
-----

You can find this package here:

- Github repository: https://github.com/twidi/django-templates-macros
- Pypi package: https://pypi.python.org/pypi/django-templates-macros


-----
Usage
-----

0) Add this app "macros" to your INSTALLED_APPS

1) In your template load the library::

    {% load macros %}

2) Define a new macro called 'my_macro' that takes args and/or kwargs
   All will be optional::

    {% macro my_macro arg1 arg2 baz="Default baz" %}
        {% firstof arg1 "default_arg1" %}
        {% if arg2 %}{{ arg2 }}{% else %}default_arg2{% endif %}
        {{ baz }}
    {% endmacro %}

3) Use the macro with string parameters or context variables::

    {% usemacro my_macro "foo" "bar" baz="KW" %}
    <br>
    {% usemacro my_macro num_pages "bar" %}

  Renders like::

    foo bar KW
    77 bar Default baz

4) Alternatively save your macros in a separate file, e.g. "mymacro.html" and load it to the current template with::

        {% loadmacros "mymacros.html" %}

    Then use these loaded macros in as described above.

Bear in mind that defined and loaded macros are local to each template
file and are not inherited through `{% extends ... %}` tags.

5) When recursive macros are needed, use the 'recurse_macro' template tag::

    {% macro MENU entries %}
    <ul>
        {% for entry in entries %}
        <li>
            <a href="{{ entry.link }}"> {{ entry.label }} </a>
            {% if entry.children %}
                {% recurse_macro MENU entry.children %}
            {% endif %}
        </li>
        {% endfor %}
    </ul>
    {% endmacro %}
    {% usemacro MENU menu.children %}


.. |PyPI Version| image:: https://img.shields.io/pypi/v/django-templates-macros.svg
   :target: https://pypi.python.org/pypi/django-templates-macros
staticjinja 5.0.0
jinja based static site generator
License: MIT
Requires Python: >=3.7,<4.0
Keywords: jinja,static,website

staticjinja
===========

.. image:: https://badge.fury.io/py/staticjinja.png
    :target: https://badge.fury.io/py/staticjinja
    :alt: PyPi Badge

.. image:: https://github.com/staticjinja/staticjinja/workflows/build/badge.svg?branch=main&event=schedule
    :target: https://github.com/staticjinja/staticjinja/actions?query=branch%3Amain
    :alt: Build and Testing Status

.. image:: https://readthedocs.org/projects/staticjinja/badge/?version=stable
    :target: https://staticjinja.readthedocs.io/en/stable/?badge=stable&style=plastic
    :alt: Documentation Status

.. image:: https://codecov.io/gh/staticjinja/staticjinja/branch/main/graph/badge.svg?token=En337ZXsPK
    :target: https://codecov.io/gh/staticjinja/staticjinja
    :alt: Test coverage status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: Code style: Black

.. image:: https://static.pepy.tech/personalized-badge/staticjinja?period=total&units=international_system&left_color=black&right_color=blue&left_text=downloads
    :target: https://pepy.tech/project/staticjinja
    :alt: PyPi downloads total

.. image:: https://static.pepy.tech/personalized-badge/staticjinja?period=month&units=international_system&left_color=black&right_color=blue&left_text=downloads/month
    :target: https://pepy.tech/project/staticjinja
    :alt: PyPi downloads per month

**staticjinja** is a library that makes it easy to build static sites using
Jinja2_.

Many static site generators are complex, with long manuals and unnecessary
features. But using template engines to build static websites is really useful.

staticjinja is designed to be lightweight (under 500 lines of source code),
and to be easy to use, learn, and extend, enabling you to focus on making your
site.

.. code-block:: bash

    $ mkdir templates
    $ vim templates/index.html
    $ staticjinja watch
    Building index.html...
    Templates built.
    Watching 'templates' for changes...
    Press Ctrl+C to stop.


Installation
------------

To install staticjinja, simply:

.. code-block:: bash

    $ pip install staticjinja

Documentation
-------------

Documentation is available at
https://staticjinja.readthedocs.io.

Contribute
----------

Please see CONTRIBUTING_.

.. _CONTRIBUTING: CONTRIBUTING.rst
.. _Jinja2: https://jinja.palletsprojects.com