Skip to main content

Flask Feather

Build Status GitHub PyPI - Python Version

A simple Tag ({% icon "name" %}) to implement Feather Icons in Flask. This is largely based of the library django_feather by Jonas Drotleff.

Install

Install flask-feather using pip.

pip install flask-feather

Quick Start

Firstly, initialise the extension within your Flask context

from flask_feather import Feather
feather = Feather(app)

This extension also supports the Flask application factory pattern by allowing you to create a Feather object and then initialised it separately for an app:

feather = Feather()

def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)

    feather.init_app(app)

Advanced setup

In addition to the wonderful icons provided in the feather set, you can supply your own svg icons, to attempt to parse them and use them in the same format. Simply initialise the extension with a directory containing .svg files that are similar in style to the feather ones. They should resemble the feather icon style as near as possible - any significant differences in formatting/structure may result in unexpected errors.

feather = Feather(import_dir='app\\static\\customsvg')

def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)

    feather.init_app(app)

Usage

It's pretty simple to use this package. From within a jinja template:

<p>{{ feather.icon('icon-name', width=32, height=32) }}</p>

If the property you're modifying has a hyphen, use an underscore instead. You can refer to icon names with either hyphens or underscores.

<p>{{ feather.icon('icon-name', stroke_width=2) }}</p>

The icon function takes the SVG source from the Feather project, applies additional attributes and return the SVG tag.

Performance

flask-feather borrows the application structure from django-feather and does not read the .svg files each time an icon is rendered. Instead, on installation, all the icons are written to a .py file. All icons are rendered on the server side, avoiding the need to call feather.replace() after the page has loaded.

Any custom icons are parsed each time the server is restarted, and not every time they're loaded.

License

Feather is licensed under the MIT License.

flask-feather is a derivative work of django-feather, both of which are licensed under the Apache License, Version 2.0:

    Modifications Copyright 2020 Tom Vos <tjvos1@gmail.com>

    Original Django-feather Copyright 2020 Jonas Drotleff <j.drotleff@desk-lab.de>

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

Metadata

Release files for flask-feather 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-feather 0.1.0
File Size Uploaded
flask-feather-0.1.0.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-feather 0.1.0
File Interpreter ABI Platform
flask_feather-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / flask-feather-0.1.0.tar.gz

Download URL flask-feather-0.1.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2794be1e28410e5a2bd793df88edf738b0af3ce2c6e7a8313725315c6b182091
BLAKE2b-256 checksum
How to use checksums
f250dfb90f7a251b7634c8fe6e06d2b7743037713316ee384773915197eed66b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3

Release files / flask_feather-0.1.0-py3-none-any.whl

Download URL flask_feather-0.1.0-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04e976f7ec598e98a0445ca8fe7cf167fa9bfd5a2cf852395a27331d7a51c8d4
BLAKE2b-256 checksum
How to use checksums
e79fbcb1c0e9d9d53002789b694998ea0f79639a28be712fcf79abb01028b70c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page