On Tue, Jun 12, 2012 at 2:59 AM, Zhenghao Huang <[email protected]> wrote:
> Hi,
>
> Thank you for your speedy response, I was quite shocked!
>
> I read through the documentation.  I am using Mako templates and they don't
> seem to have something for that.  Do you have any real examples of it's use
> in the templates.  My mind is thinking along the lines of Minimatic's way:
>
> Inside base.mako:
> ${h.javascript_link('/static/js/base.js', dict(file='/static/js/cache.js',
> minify='minify'))}

The way I treat this is to make these decisions in a separate file and
name my assets in an asset environment.
I use pyramid_webassets and add the webassets environment to my
template globals.

@subscriber(BeforeRender)
def add_global(event):
    environment = event['request'].registry.queryUtility(IWebAssetsEnvironment)
    event['environment'] = environment

Where IWebAssetsEnvironment comes from pyramid_webassets.

Then in my template I have things like:

  <link rel="stylesheet"
        tal:attributes="href href"
        tal:repeat="href environment['css'].urls()" />

which is a chameleon template. Here I get a single link tag if
environment['css'] is concatenated (+minified) and multiple if not.
Running with webassets in debug mode is all it takes to flip the
switch, and I do that in my paste-style .ini.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to