I just started using webassets with mako templates for an existing
project. All assets are included in a site template (site.mako).
Assets come from various sources, e.g. the deform package. So what I
do (which may be crazy): Have my build script parse site.mako to
assemble the bundles (resolving resource specs of the form
'deform:static/...' to absolute paths). This way, using a new asset
does only require adding it to site.mako.
So far I have not run into a show-stopper with this.

regards
robert

On Wed, Jun 13, 2012 at 8:25 AM, Randall Leeds <randall.le...@gmail.com> wrote:
> On Tue, Jun 12, 2012 at 2:59 AM, Zhenghao Huang <zhengha...@gmail.com> 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 pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to 
> pylons-discuss+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/pylons-discuss?hl=en.
>

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

Reply via email to