Giter Club home page Giter Club logo

Comments (21)

maccesch avatar maccesch commented on May 19, 2024

++ Vote Up

from django-sekizai.

ojii avatar ojii commented on May 19, 2024

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.

maccesch avatar maccesch commented on May 19, 2024

Hm, you're right, of course. Maybe this is more of an django-crompressor issue than a sekizai one.

from django-sekizai.

alsoicode avatar alsoicode commented on May 19, 2024

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.

ojii avatar ojii commented on May 19, 2024

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.

alsoicode avatar alsoicode commented on May 19, 2024

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.

maccesch avatar maccesch commented on May 19, 2024

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.

ojii avatar ojii commented on May 19, 2024

The option proposed by @maccesch is not possible with the django template language. That's why I propose the callback workaround.

from django-sekizai.

ojii avatar ojii commented on May 19, 2024

Fixed in 0a7ec69

from django-sekizai.

mbrochh avatar mbrochh commented on May 19, 2024

This is exciting news!!! Thanks a lot!

from django-sekizai.

alsoicode avatar alsoicode commented on May 19, 2024

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.

ojii avatar ojii commented on May 19, 2024

I'm sorry but what you do with the data rendered using sekizai is out of the scope of this project

from django-sekizai.

timmyomahony avatar timmyomahony commented on May 19, 2024

@btaylordesign This should do it: https://gist.github.com/1311010

from django-sekizai.

alsoicode avatar alsoicode commented on May 19, 2024

Works like a charm! This is great. Now we get the benefits of both. Many thanks for the extra callback @ojii.

from django-sekizai.

ojii avatar ojii commented on May 19, 2024

Very nice @pastylegs, maybe make it an installable package?

from django-sekizai.

brutasse avatar brutasse commented on May 19, 2024

@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.

timmyomahony avatar timmyomahony commented on May 19, 2024

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.

electroniceagle avatar electroniceagle commented on May 19, 2024

did this get packaged anywhere?

from django-sekizai.

ojii avatar ojii commented on May 19, 2024

no it didn't. I'm of course accepting pull requests if my speed of development is not to your satisfaction ;-)

from django-sekizai.

diox avatar diox commented on May 19, 2024

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.

jrief avatar jrief commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.