toranb / django-ember-precompile Goto Github PK
View Code? Open in Web Editor NEWember.js precompiler for projects that use the django compressor
License: MIT License
ember.js precompiler for projects that use the django compressor
License: MIT License
Hi,
I am hoping to get some guidance on an issue I am having with this particular precompiler. Everything works just as it should when running with 'python manage.py runserver' but when I use uwsgi to run the application it will not work.
The error I am receiving is
ValueError at /
Empty module name
It is occurring because of this call in base.py of django_compressor on line 249:
mod = import_module(mod_name)
At this point the mod_name variable is empty. It is empty because of the call to get_mod_func a few lines above:
mod_name, cls_name = get_mod_func(filter_or_command)
It turns out the get_mod_func method just splits the 'filter_or_command' variable based on the first '.' on the right in this file of django_compressor - utils/init.py:
return callback[:dot], callback[dot + 1:]
When using django-ember-precompile the value of filter_or_command is this:
'./node_modules/django-ember-precompile/bin/django-ember-precompile {infile}'
which means the call to get_mod_func will return this:
'','./node_modules/django-ember-precompile/bin/django-ember-precompile {infile}'
Which causes the import_module call to fail due to the empty value.
I am sorry if this issue is not specifically related to django-ember-precompile but I would love if you could nudge me in to the right direction for tracking this down and I would greatly appreciate it.
The strange thing is that this only occurs when using uwsgi to run the app and not through the regular runserver
Leigh
Toran,
I'm not very familiar with the compression pipeline in Django so I'm reaching out in case you have a guess.
Do you think it's possible we could pass a directory and it could scan and inject instead of having to list 100 templates?
Or do you think I should just lazily precompile them all and inject them in a single bundled file?
when you run rake dist on the ember.js project is generates a nice script called ember-template-compiler.js
which as the name describes compiles ember templates nicely.
when using that, all you need is handlebars, no jquery and no full ember.
This also means no need for jsdom, which actually has requirements of its own that need compilation. Installing a compiler on windows just to get precompilation seems drastic to me ๐
I will probably not be using this project in production simply because node is kinda weird on windows with respect to file paths etc.
I plan on using PyExecJS with node as a backend to avoid having to call out to a cmd in django-compressor (it will be its own filter)
Just figured I would let you know you can cut off almost all your current dependencies and make this very slim.
Hi, would you consider making a new release to support Handlebars 2.0? The changes necesary are pretty minimal and can be found in https://github.com/lewtds/django-ember-precompile . Thanks!
Noticed some problems with an npm install of django-ember-precompile of late.
Installation works fine, but when it's used you get:
"TypeError: Object [ null ] has no method 'createWindow'"
It looks to be related to django-ember-precompile installing one of the later jsdom packages, specifically the 1.0.0-pre.X versions.
Currently working around it by pre-installing [email protected] prior to installing django-ember-precompile - that seems to satisfy DEP's dependencies and avoids (on a clean install) it pulling in a problematic version by itself.
<script src="{% static 'templates/foo.handlebars' %}?name=foobar"
type="text/x-handlebars"></script>
or within foo.handlebars on the first line
something like this would remove the need for the currently strict filename/path requirements
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.