Comments (5)
I've implemented this as a bundle filter exfm@90bfd2e
We then use it in our environment like so.
js_templates = Bundle('js/templates/*', filters='jst', output='js/templates.js')
environment.register('js_templates', js_templates)
libs = ['jquery-1.6.2', 'underscore', 'backbone']
libs_js_bundle = Bundle(*['js/libs/%s.js' % f for f in libs])
app_base_js_bundle = Bundle('js/app/models.js', 'js/app/views.js')
app_js = Bundle('js/config.js', libs_js_bundle, js_templates, app_base_js_bundle, output='js/app.js')
environment.register('app_js', app_js)
I has cleaned up our code substantially and has made testing significantly easier (templates used to be scattered in Jinja templates, making them hard to include without dupes). Did you have something else in mind for this?
from webassets.
I'm not sure what I had in mind exactly. Something about using a filter seems to irk me the wrong way, but I'm not sure. Maybe the way you need to combine both input and output filters via a shared state.
At the same time, it is without a doubt a very elegant solution. Let's merge it.
A couple notes though:
- Is there a reason why you are opening and reading the file in input() yourself? If you were to just read from the "_in" stream instead then other filters could be applied to preprocess the templates.
- When determine the template name, you seem to assume they are located in a "templates/" directory. That seems wrong. I think the proper way to do this is storing the full source_path in "self.templates", and then making the output() function smart enough to determine the common prefix of all templates, ignoring it, and using the rest as the accessor (this is how Jammit does it). So a template may be accessed as Templates.license, or, if the templates are organised subdirectories, then it might be Templates['public/license'].
Finally, if you find the time to add a test for the filter, that would mean I don't have to ;)
from webassets.
Sweet. Really just wanted to see what you thought about this. I'll add more 1:1 jammit stuff along with your notes.
from webassets.
This is now implemented in master as a filter. Thanks Lucas.
from webassets.
Sweettt
from webassets.
Related Issues (20)
- jsmin/rjsmin removes blanks in ES6 Template Strings HOT 1
- Fail when packing an external resource HOT 4
- YAMLLoadWarning yaml.load is deprecated
- Bundles cannot be replaced/re-added
- --line-comments is deprecated
- LibSASS - Unable to use other compile options like source_comments
- Version 2: Couldn't find preset HOT 3
- Threading.isAlive was removed in Python 3.9
- Load_builtin_filters doesn't work as expected with PyInstaller
- Deprecation warning due to invalid escape sequences in Python 3.7
- Fix simple typo: ultimatily -> ultimately
- Closure: ReferenceError: $jscomp is not defined
- Copy assets
- SCSS filter runs command sass without --scss HOT 2
- Add a tool to remove unused css
- How to configure filters using the YAML config option? Specifically cssrewrite. HOT 1
- Jinja2 Base template loaded twice when upgrading werkzeug package
- Add a way to get all bundle names
- 'out' is deprecated and will stop functioning in TypeScript 5.5
- mode merge=False not implemented in flask_assets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webassets.