Question

I'm running python (2.7) with Flask with webassets (0.9) and i done all the steps described in the docs for running dustjs, but all results in an empty file. The strangest thing is that when I run dusty directly in the dir with my templates it works fine.

Here is my configs.

myapp.py

assets_env = Environment(app)

assets.py

common_dust = Bundle("dust/*", filters='dustjs', output='gen/dust_compiled.js')

templates/index.html

Was it helpful?

Solution

I ran into a similar issue the other day, although I'm not using flask, but pyramid.

Have you tried changing the first Bundle parameter from 'dust/*' to just 'dust'? I believe webassets passes this argument directly to dusty, and dusty expects a directory path to the parent template directory as input, not individual template names.

If you pass a directory, however, the latest version of webassets can give errors if caching is turned on because the cache management code is not expecting a directory for the first parameter; I just disable caching to get around this. If you disable caching, you must also provide a different mechanism for storing manifests (if you are using features that require manifests, see docs).

Also, I have had to add a depends="dust/" parameter to bundle (add more subdirectories //* if necessary) to get webassets to regenerate the templates when changes are made.

So I am suggesting adding these config parameters:

assets_env.cache = False
assets_env.manifest = "file:gen/dusty.manifest"

And changing the bundle instantiation to:

common_dust = Bundle("dust", filters='dustjs', depends="dust/*", output='gen/dust_compiled.js') 

Hopefully a future version of webassets will play nicer with dustjs integration. The main problem seems to be dusty requiring a directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top