https://github.com/rancorm/hip-flask
Lightweight Flask extension to simplify the integration of CSS and JavaScript files into your applications
https://github.com/rancorm/hip-flask
flask html python
Last synced: about 1 month ago
JSON representation
Lightweight Flask extension to simplify the integration of CSS and JavaScript files into your applications
- Host: GitHub
- URL: https://github.com/rancorm/hip-flask
- Owner: rancorm
- License: bsd-3-clause
- Created: 2024-01-17T07:10:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-19T17:19:24.000Z (over 1 year ago)
- Last Synced: 2025-01-22T15:45:51.367Z (over 1 year ago)
- Topics: flask, html, python
- Language: Python
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hip-flask
Lightweight Flask extension to simplify the integration of CSS and JavaScript files
into your applications.
## Start here
Install the extension:
```sh
pip install hip-flask
```
Considering the minimal flask application factory below in `hipapp.py` as an example:
```python
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.
### Stylesheets
```python
{% block stylesheets %}
{% for css in macros.hip_links() %}{{ css.as_tag() }}{% endfor %}
{% endblock %}
```
### Meta tags
```python
{% block metas %}
{% for meta in macros.hip_metas() %}{{ meta.as_tag() }}{% endfor %}
{% endblock %}
```
## Contributing
You know the drill. Fork and get to work.