Comments (21)
++ Vote Up
from django-sekizai.
How does this proposed solution sound like?
Templates::
{% render_block "blockname" process "myproject.somemodule.process_render_block" %}
myproject/somemodule.py:
def process_render_block(data):
"""
data is the **rendered** output of the block.
"""
return do_some_compressor_magic(data)
django-sekizai would not actually implement any compressing.
from django-sekizai.
Hm, you're right, of course. Maybe this is more of an django-crompressor issue than a sekizai one.
from django-sekizai.
I really like the idea behind sekizai, but without being able to combine and minify the css/js block it can increase the number of http requests. Django-compressor is awesome because it does its work at the template level instead of the configuration level. This makes its implementation ridiculously simple.
I'm not sure where the conflict between these two packages is, as I haven't had time to do any investigation, but it would seem like the django-compressor functionality would have to get baked into sekizai.
from django-sekizai.
no this is a problem in sekizai. The question is how to most elegantly solve it. Currently allowing a post-processing callback to render_block seems most sensible to me.
from django-sekizai.
I wouldn't mind specifying a callback function on the addtoblock template tag in sekizai. I think it would be a good idea to have it as an option. Sometimes there are JavaScript files that just can't be combined, so you might want to have an addtoblock that does combination/minification and one that doesn't.
from django-sekizai.
A callback in render_block would be nice, but doing this would be even nicer I think:
{% compress js %}
{% render_block "js" %}
{% endcompress %}
And it should be feasible. But it would mean changes to django compress.
from django-sekizai.
The option proposed by @maccesch is not possible with the django template language. That's why I propose the callback workaround.
from django-sekizai.
Fixed in 0a7ec69
from django-sekizai.
This is exciting news!!! Thanks a lot!
from django-sekizai.
Awesome. So I'm looking through the source on django-compressor, and I'm wondering which function would get called by the sekizai post-processing callback...
from django-sekizai.
I'm sorry but what you do with the data rendered using sekizai is out of the scope of this project
from django-sekizai.
@btaylordesign This should do it: https://gist.github.com/1311010
from django-sekizai.
Works like a charm! This is great. Now we get the benefits of both. Many thanks for the extra callback @ojii.
from django-sekizai.
Very nice @pastylegs, maybe make it an installable package?
from django-sekizai.
@ojii maybe a django-sekizai-contrib package with this in it as well? https://gist.github.com/932760 :)
@pastylegs do you want to do it?
from django-sekizai.
Yea, that's a good idea. I can package it up when I get a chance. I think the contrib idea is also a nice idea, particularly as people will be using sekizai via django-cms
from django-sekizai.
did this get packaged anywhere?
from django-sekizai.
no it didn't. I'm of course accepting pull requests if my speed of development is not to your satisfaction ;-)
from django-sekizai.
FWIW if anyone is still following this issue: this pull request django-compressor/django-compressor#334 over at django_compressor proposes to merge this gist to django_compressor itself, in the contrib folder. I think this is a good idea, and it was also suggested in #18, but if anyone has some objection about it, please comment on the pull request, thanks!
from django-sekizai.
I have created another pull request in django-compressor to change the Sekizai postprocessor code.
This is required to allow the mixed usage of
{% addtoblock "css" %}<link href="..." />{% endaddtoblock %}
and
{% addtoblock "js" %}<srcipt src="..." ></scipt>{% endaddtoblock %}
as for self hosted files (and hence compressible), as well as for files available through CDNs (and hence uncompressible).
With the current version of Sekizai's postprocessor, the latter would raise an UncompressableFileError
.
Since this compressor postproessor is likely to be used by Sekizai users only, I'd like to inform you so that you can review it.
from django-sekizai.
Related Issues (20)
- Documentation on readthedocs is out of date HOT 2
- Add support for Django 3.2 HOT 4
- Error when adding Sekizai HOT 1
- 3.0.0: Tests missing in sdist tarball on pypi.org HOT 4
- The use of setup.py test is deprecated HOT 1
- RTD maintenance HOT 2
- helpers._scan_namespaces silently gives up when encountering a with_data node (SekizaiParser dropping template nodes?) HOT 13
- Code alerts by lgtm HOT 1
- Django 4.2 support? HOT 2
- Is it possible to detect an empty block?
- Missing tag for 1.0.0 release HOT 2
- pep8 dependency should be replaced by pycodestyle HOT 1
- Use flake8 instead of pep8 HOT 1
- tests missing from pypi sdist HOT 3
- Can`t use render_to_string without a given request HOT 1
- Django 3.1 compatibility HOT 2
- Remove compatibility import of Context in django.template.base HOT 1
- Import Error with Django 3.1 HOT 1
- 2.0.0 installs tests top-level HOT 1
- sekizai tag addtoblock silently ignored HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-sekizai.