soulclick-tablericons


Namesoulclick-tablericons JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryUse tablericons in your Django and Jinja templates.
upload_time2024-12-17 21:29:20
maintainerNone
docs_urlNone
authorJoshua Gartmeier
requires_python>=3.9
licenseNone
keywords django jinja
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===========
tablericons
===========

.. image:: https://img.shields.io/github/actions/workflow/status/gartmeier/tablericons/main.yml.svg?branch=main&style=for-the-badge
   :target: https://github.com/gartmeier/tablericons/actions?workflow=CI

.. image:: https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge
   :target: https://github.com/gartmeier/tablericons/actions?workflow=CI

.. image:: https://img.shields.io/pypi/v/soulclick-tablericons.svg?style=for-the-badge
   :target: https://pypi.org/project/soulclick-tablericons/

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
   :target: https://github.com/psf/black

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge
   :target: https://github.com/pre-commit/pre-commit
   :alt: pre-commit

Use `tablericons <https://tablericons.com/>`__ in your Django and Jinja templates.

Requirements
------------

Python 3.9 to 3.13 supported.

Django 4.2 to 5.1 supported.

Usage
-----

The ``soulclick-tablericons`` package supports both Django templates and Jinja templates.
Follow the appropriate guide below.

Django templates
~~~~~~~~~~~~~~~~

1. Install with ``python -m pip install soulclick-tablericons[django]``.

2. Add to your ``INSTALLED_APPS``:

   .. code-block:: python

       INSTALLED_APPS = [
           ...,
           "tablericons",
           ...,
       ]

Now your templates can load the template library with:

.. code-block:: django

    {% load tablericons %}

Alternatively, make the library available in all templates by adding it to `the builtins option <https://docs.djangoproject.com/en/stable/topics/templates/#django.template.backends.django.DjangoTemplates>`__:

.. code-block:: python

    TEMPLATES = [
        {
            "BACKEND": "django.template.backends.django.DjangoTemplates",
            # ...
            "OPTIONS": {
                # ...
                "builtins": [
                    ...,
                    "tablericons.templatetags.tablericons",
                    ...,
                ],
            },
        }
    ]

The library provides these tags to render SVG icons in their corresponding styles:

* ``tablericon_outline``
* ``tablericon_filled``

The tags take these arguments:

* ``name``, positional: the name of the icon to use.
  You can see the icon names on the `tablericons.com grid <https://tablericons.com/>`__.

* ``size``, keyword: an integer that will be used for the width and height attributes of the output ``<svg>`` tag.
  Defaults to the icons’ designed sizes: ``24`` for outline and solid, ``20`` for mini, and ``16`` for micro.
  Can be ``None``, in which case no width or height attributes will be output.

* Any number of keyword arguments.
  These will be added as attributes in the output HTML.
  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. ``data-`` attributes.

  Most attributes will be added to the ``<svg>`` tag containing the icon, but these attributes will be attached to the inner ``<path>`` tags instead:

  * ``stroke-linecap``
  * ``stroke-linejoin``
  * ``vector-effect``

Examples
^^^^^^^^

An outline “school” icon:

.. code-block:: django

    {% tablericon_outline "school" %}

The same icon, solid, at 40x40 pixels, and a CSS class:

.. code-block:: django

    {% tablericon_outline "school" size=40 class="mr-4" %}

That icon again, but with the paths changed to a narrower stroke width, and a "data-controller" attribute declared:

.. code-block:: django

    {% tablericon_outline "school" stroke_width=1 data_controller="academia" %}

Jinja templates
~~~~~~~~~~~~~~~

1. Install with ``python -m pip install soulclick-tablericons[jinja]``.

2. Adjust your Jinja ``Environment`` to add the global ``tablericon_*`` functions from ``tablericons.jinja``.
   For example:

   .. code-block:: python

       from tablericons.jinja import (
           tablericon_outline,
           tablericon_filled,
       )
       from jinja2 import Environment

       env = Environment()
       env.globals.update(
           {
               "tablericon_outline": tablericon_outline,
               "tablericon_filled": tablericon_filled,
           }
       )

Now in your templates you can call those functions, which render ``<svg>`` icons corresponding to the icon styles in the set.
The functions take these arguments:

* ``name``, positional: the name of the icon to use.
  You can see the icon names on the `tablericons.com grid <https://tablericons.com/>`__.

* ``size``, keyword: an integer that will be used for the width and height attributes of the output ``<svg>`` tag.
  Defaults to the icons’ designed sizes: ``24`` for outline and solid, ``20`` for mini, and ``16`` for micro.
  Can be ``None``, in which case no width or height attributes will be output.

* Any number of keyword arguments.
  These will be added as HTML attributes to the output HTML.
  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. ``data-`` attributes.

  Most attributes will be added to the ``<svg>`` tag containing the icon, but these attributes will be attached to the inner ``<path>`` tags instead:

  * ``stroke-linecap``
  * ``stroke-linejoin``
  * ``vector-effect``

Note: unlike the SVG code you can copy from `tablericons.com <https://tablericons.com/>`__, there is no default ``class``.

Examples
^^^^^^^^

An outline “egg” icon:

.. code-block:: jinja

    {{ tablericon_outline("egg") }}

The same icon, solid, at 40x40 pixels, and a CSS class:

.. code-block:: jinja

    {{ tablericon_filled("egg", size=40, class="mr-4") %}

That icon again, but with the paths changed to a narrower stroke width, and a "data-controller" attribute declared:

.. code-block:: jinja

    {{ tablericon_outline("egg", stroke_width=1, data_controller="academia") %}

Acknowledgements
----------------

This package is heavely inspired by `Adam Johnson's heroicons <https://github.com/adamchainz/heroicons>`__. It's actually mostly copied from it so a huge thanks Adam!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "soulclick-tablericons",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "Django Jinja",
    "author": "Joshua Gartmeier",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/52/0f/f184fdb421680db4946699232cbb4346b97a91ac8b28a4b359c652481329/soulclick_tablericons-1.0.0.tar.gz",
    "platform": null,
    "description": "===========\ntablericons\n===========\n\n.. image:: https://img.shields.io/github/actions/workflow/status/gartmeier/tablericons/main.yml.svg?branch=main&style=for-the-badge\n   :target: https://github.com/gartmeier/tablericons/actions?workflow=CI\n\n.. image:: https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge\n   :target: https://github.com/gartmeier/tablericons/actions?workflow=CI\n\n.. image:: https://img.shields.io/pypi/v/soulclick-tablericons.svg?style=for-the-badge\n   :target: https://pypi.org/project/soulclick-tablericons/\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge\n   :target: https://github.com/psf/black\n\n.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge\n   :target: https://github.com/pre-commit/pre-commit\n   :alt: pre-commit\n\nUse `tablericons <https://tablericons.com/>`__ in your Django and Jinja templates.\n\nRequirements\n------------\n\nPython 3.9 to 3.13 supported.\n\nDjango 4.2 to 5.1 supported.\n\nUsage\n-----\n\nThe ``soulclick-tablericons`` package supports both Django templates and Jinja templates.\nFollow the appropriate guide below.\n\nDjango templates\n~~~~~~~~~~~~~~~~\n\n1. Install with ``python -m pip install soulclick-tablericons[django]``.\n\n2. Add to your ``INSTALLED_APPS``:\n\n   .. code-block:: python\n\n       INSTALLED_APPS = [\n           ...,\n           \"tablericons\",\n           ...,\n       ]\n\nNow your templates can load the template library with:\n\n.. code-block:: django\n\n    {% load tablericons %}\n\nAlternatively, make the library available in all templates by adding it to `the builtins option <https://docs.djangoproject.com/en/stable/topics/templates/#django.template.backends.django.DjangoTemplates>`__:\n\n.. code-block:: python\n\n    TEMPLATES = [\n        {\n            \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n            # ...\n            \"OPTIONS\": {\n                # ...\n                \"builtins\": [\n                    ...,\n                    \"tablericons.templatetags.tablericons\",\n                    ...,\n                ],\n            },\n        }\n    ]\n\nThe library provides these tags to render SVG icons in their corresponding styles:\n\n* ``tablericon_outline``\n* ``tablericon_filled``\n\nThe tags take these arguments:\n\n* ``name``, positional: the name of the icon to use.\n  You can see the icon names on the `tablericons.com grid <https://tablericons.com/>`__.\n\n* ``size``, keyword: an integer that will be used for the width and height attributes of the output ``<svg>`` tag.\n  Defaults to the icons\u2019 designed sizes: ``24`` for outline and solid, ``20`` for mini, and ``16`` for micro.\n  Can be ``None``, in which case no width or height attributes will be output.\n\n* Any number of keyword arguments.\n  These will be added as attributes in the output HTML.\n  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. ``data-`` attributes.\n\n  Most attributes will be added to the ``<svg>`` tag containing the icon, but these attributes will be attached to the inner ``<path>`` tags instead:\n\n  * ``stroke-linecap``\n  * ``stroke-linejoin``\n  * ``vector-effect``\n\nExamples\n^^^^^^^^\n\nAn outline \u201cschool\u201d icon:\n\n.. code-block:: django\n\n    {% tablericon_outline \"school\" %}\n\nThe same icon, solid, at 40x40 pixels, and a CSS class:\n\n.. code-block:: django\n\n    {% tablericon_outline \"school\" size=40 class=\"mr-4\" %}\n\nThat icon again, but with the paths changed to a narrower stroke width, and a \"data-controller\" attribute declared:\n\n.. code-block:: django\n\n    {% tablericon_outline \"school\" stroke_width=1 data_controller=\"academia\" %}\n\nJinja templates\n~~~~~~~~~~~~~~~\n\n1. Install with ``python -m pip install soulclick-tablericons[jinja]``.\n\n2. Adjust your Jinja ``Environment`` to add the global ``tablericon_*`` functions from ``tablericons.jinja``.\n   For example:\n\n   .. code-block:: python\n\n       from tablericons.jinja import (\n           tablericon_outline,\n           tablericon_filled,\n       )\n       from jinja2 import Environment\n\n       env = Environment()\n       env.globals.update(\n           {\n               \"tablericon_outline\": tablericon_outline,\n               \"tablericon_filled\": tablericon_filled,\n           }\n       )\n\nNow in your templates you can call those functions, which render ``<svg>`` icons corresponding to the icon styles in the set.\nThe functions take these arguments:\n\n* ``name``, positional: the name of the icon to use.\n  You can see the icon names on the `tablericons.com grid <https://tablericons.com/>`__.\n\n* ``size``, keyword: an integer that will be used for the width and height attributes of the output ``<svg>`` tag.\n  Defaults to the icons\u2019 designed sizes: ``24`` for outline and solid, ``20`` for mini, and ``16`` for micro.\n  Can be ``None``, in which case no width or height attributes will be output.\n\n* Any number of keyword arguments.\n  These will be added as HTML attributes to the output HTML.\n  Underscores in attribute names will be replaced with dashes, allowing you to define e.g. ``data-`` attributes.\n\n  Most attributes will be added to the ``<svg>`` tag containing the icon, but these attributes will be attached to the inner ``<path>`` tags instead:\n\n  * ``stroke-linecap``\n  * ``stroke-linejoin``\n  * ``vector-effect``\n\nNote: unlike the SVG code you can copy from `tablericons.com <https://tablericons.com/>`__, there is no default ``class``.\n\nExamples\n^^^^^^^^\n\nAn outline \u201cegg\u201d icon:\n\n.. code-block:: jinja\n\n    {{ tablericon_outline(\"egg\") }}\n\nThe same icon, solid, at 40x40 pixels, and a CSS class:\n\n.. code-block:: jinja\n\n    {{ tablericon_filled(\"egg\", size=40, class=\"mr-4\") %}\n\nThat icon again, but with the paths changed to a narrower stroke width, and a \"data-controller\" attribute declared:\n\n.. code-block:: jinja\n\n    {{ tablericon_outline(\"egg\", stroke_width=1, data_controller=\"academia\") %}\n\nAcknowledgements\n----------------\n\nThis package is heavely inspired by `Adam Johnson's heroicons <https://github.com/adamchainz/heroicons>`__. It's actually mostly copied from it so a huge thanks Adam!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Use tablericons in your Django and Jinja templates.",
    "version": "1.0.0",
    "project_urls": {
        "Changelog": "https://github.com/gartmeier/tablericons/blob/main/CHANGELOG.rst",
        "Repository": "https://github.com/gartmeier/tablericons"
    },
    "split_keywords": [
        "django",
        "jinja"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7ec63cec549c73bf87d973a88a40078e956107f4adb4c0368b16737ea17753f",
                "md5": "0b9b723f1c0bc252e4cb7e7f102d9b4b",
                "sha256": "01f90da489b25d735faec12191f2e7e1d08ff7a6d395e1854d3139b9016ae75f"
            },
            "downloads": -1,
            "filename": "soulclick_tablericons-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b9b723f1c0bc252e4cb7e7f102d9b4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 2003868,
            "upload_time": "2024-12-17T21:29:17",
            "upload_time_iso_8601": "2024-12-17T21:29:17.633350Z",
            "url": "https://files.pythonhosted.org/packages/b7/ec/63cec549c73bf87d973a88a40078e956107f4adb4c0368b16737ea17753f/soulclick_tablericons-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "520ff184fdb421680db4946699232cbb4346b97a91ac8b28a4b359c652481329",
                "md5": "573118eafb6a2ca4f4a04b3372529fa7",
                "sha256": "18295b3a20189a1cf3bc98978e190d914b7a8ebf5ee65ea9734b2d2bc3b1e189"
            },
            "downloads": -1,
            "filename": "soulclick_tablericons-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "573118eafb6a2ca4f4a04b3372529fa7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 2002868,
            "upload_time": "2024-12-17T21:29:20",
            "upload_time_iso_8601": "2024-12-17T21:29:20.607611Z",
            "url": "https://files.pythonhosted.org/packages/52/0f/f184fdb421680db4946699232cbb4346b97a91ac8b28a4b359c652481329/soulclick_tablericons-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 21:29:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gartmeier",
    "github_project": "tablericons",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "soulclick-tablericons"
}
        
Elapsed time: 0.47270s