Lightweight Flask extension to simplify the integration of CSS and JavaScript files into your applications.
Install the extension:
pip install hip-flask
Considering the minimal flask application factory below in hipapp.py
as an example:
from flask import Flask
from hip_flask import HipExtension
def create_app():
app = Flask(__name__)
hip = HipExtension(app)
# Meta tags
hip.meta(charset=hip.Meta.CHARSET)
hip.meta(name="description", content="Timeline event tracker")
hip.meta(name="keywords", content=["HTML", "CSS", "JavaScript"])
# Stylesheets
hip.static_link("css/hipapp.css")
# Scripts
hip.static_script("js/hipapp.js")
@app.route('/hello')
def hello():
return 'Hello, World!'
return app
In the template use macros hip_links
, hip_scripts
, or hip_metas
to retrieve link,
script, and meta tags respectively for use in the template.
{% block stylesheets %}
{% for css in macros.hip_links() %}{{ css.as_tag() }}{% endfor %}
{% endblock %}
{% block metas %}
{% for meta in macros.hip_metas() %}{{ meta.as_tag() }}{% endfor %}
{% endblock %}
You know the drill. Fork and get to work.