No project description provided
Project description
head-context
Easily manage your assets in meta tags (scripts, css, preload etc.) from anywhere in the template code (and outside).
Why
Imagine a form widget, which requires a heavy image processing library that we want to include ONLY IF the widget itself was rendered. Thanks to head-context
you can specify what resources you need locally (in template fragments, widgets and so on) yet load them in the head
section of your page with ease.
What does it do?
<!doctype html>
<html>
<head>
<title>My Title!</title>
<!-- this is where we want all our js/css rendered to be rendered -->
{{ meta_placeholder() }}
</head>
<body>
{% include "my-cool-component.html" %}
</body>
</html>
And my-cool-component.html
:
<!-- we can call these from anywhere and they will be automatically rendered in the right place! -->
{% do push_js('/static/cool-component.js', mode="async") %}
{% do push_css('/static/cool-component.css') %}
{% do push_preload('/static/some-image-we-need.png', 'image') %}
<div class="my-cool-component">
<!-- ... --->
</div>
And that's pretty much it. You can push_js
/push_css
/push_preload
from anywhere in the template (and even outside of templates) and it will be automatically attached to the page being rendered.
Features
- Supports scripts, styles and preload directives
- Works with Jinja2
- Can be used outside of templates too
- if you want to render a custom (form) widget for example
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
Hashes for head_context-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c9ad568fb4319074342d8c5a7889add00e9e3f83dceae1e495e343e88a7a903 |
|
MD5 | 406b76d57637519122589f473a5ce01a |
|
BLAKE2b-256 | 4546755f3297a883f0a0c40718ef559b72b91ac39e3e9f33d2217342687f9421 |