Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compresses javascript when it is %included%. #7

Open
senyai opened this issue Nov 3, 2013 · 2 comments
Open

Compresses javascript when it is %included%. #7

senyai opened this issue Nov 3, 2013 · 2 comments

Comments

@senyai
Copy link

senyai commented Nov 3, 2013

Like this:

<script type="text/javascript">
    {% include "script.js" %}
</script>
@untitaker
Copy link

I think that is out of the scope of this extension.

@senyai
Copy link
Author

senyai commented Nov 4, 2013

Example:

import jinja2, jinja2.loaders
from jinja2htmlcompress import HTMLCompress

TEMPLATE = """
<html>
    <title>Hello, world!</title>
    <script type="text/javascript">{% include "js.js" %}</script>
</html>
"""

JS = """
// sure, you will see the alert
alert("hello :)");
"""

loader = jinja2.loaders.DictLoader({'js.js': JS})

env = jinja2.Environment(
    extensions=[HTMLCompress],
    loader=loader,
)
print env.from_string(TEMPLATE).render().encode('utf-8')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants