Easy to use breadcrumbs for webpages using Flask.
Project description
QDCrumbs
Quick & Dirty Breadcrumbs
Description
This package provides a simple way to add dynamic breadcrumbs to a Flask application. The breadcrumbs can easily be used in a jinja2 template.
QDcrumbs work in both the main Flask application and in Flask Blueprints, and currently support a single variable page, simply import qdcrumb from qdcrumbs and follow the examples below.
Get started:
Getting started with qdcrumbs is easy! Import the qdcrumb object (from qdcrumbs import qdcrumb) and follow the example below.
Examples
The following examples work both in the main Flask app and Blueprints!
Importing qdcrumbs:
from flask import Flask
from qdcrumbs import qdcrumb
Standard Usage:
@app.route('/')
def my_page():
x = qdcrumb.get_crumbs()
return render_template('/my_page.html', breadcrumbs=x)
With a variable name:
@app.route('/path/to/<var>')
def my_page(var):
x = qdcrumb.get_crumbs(var)
return render_template(f'/path/to/{var}.html', breadcrumbs=x)
IMPORTANT!
qdcrumb.get_crumbs() must be called from within a function that points to a resource's route: i.e. a function with the route decorator (@app.route | @blueprint.route). This is because the url is resolved via Flask using url_for() which takes the name of the function that was decorated.
Breadcrumbs are provided as a list of the Breadcrumb class and have the following attributes:
- url --> Path to the current page/resource & preceding pages.
- text --> Name of the current page/resource.
The breadcrumbs do not provide the site's root directory, this can be added manually trivially (see html jinja2 template example below).
<div>
<!--
Include a static link to the site root (Index.html)
(The Application's root must be added manually)
-->
<a href="{{ url_for('index.html')}}">Index</a>
<!--Loop through the breadcrumbs to this resource-->
{%- for breadcrumb in breadcrumbs -%}
<a href="{{ breadcrumb.url }}"> / {{ breadcrumb.text }}</a>
{%- endfor -%}
</div>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file qdcrumbs-0.0.1.tar.gz
.
File metadata
- Download URL: qdcrumbs-0.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2e9362412cd10c9a1c55ce2dc2603ceef7b4f2c96ed90517f40502f5804110b |
|
MD5 | a7b3a62bf769acdb74c32cb5b7e8be9e |
|
BLAKE2b-256 | 30073ffc640338bd1e20eb521b74e2ebb2b25cc330a734fabccdcb33cd4c481c |
File details
Details for the file qdcrumbs-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: qdcrumbs-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e843d5a77cbfdd0fbc341785f0d39ce1857740615c585ac8cb667d036d19406 |
|
MD5 | 6f92b7b3e949d33a98a010ef03828ad0 |
|
BLAKE2b-256 | ac8631ed367f651513c734ff19474ddfd6f137c15f0a1549431700272ddaadf6 |