mjumbewu / django-jstemplate

Embed Javascript templates (mustache.js and more) into Django templates with minimal fuss.
Other
41 stars 16 forks source link

Makemessages doesn't support subdirectories #3

Closed anttihirvonen closed 10 years ago

anttihirvonen commented 11 years ago

Hi!

First of all, this looks a great library! I'm trying to integrate it into a project which uses Handlebars templates. However, it seems that the patched makemessages command doesn't support subdirectories under Javascript template directories.

Example: Let's say I have app test in INSTALLED_APPS, and test/jstemplates is my Javascript template directory for that app. Now, if I put a template handlebars_test.hbs to path test/jstemplates/handlebars_test.hbs, then {% handlebars 'handlebars_test.hbs' %} works beautifully in templates and python manage.py makemessages --all -e html,hbs finds the translation string inside the template correctly.

However, if I put my template to test/jstemplates/test/something/handlebars_test.hbs, {% handlebars 'test/something/handlebars_test.hbs' %} works as expected, but makemessages won't find the translation strings. This seems to be related to how templatize finds all Javascript templates with find("(.*)") (https://github.com/mjumbewu/django-jstemplate/blob/master/jstemplate/management/commands/makemessages.py#L45), which doesn't correctly capture templates in subdirectories.

mjumbewu commented 11 years ago

Hm, thanks for catching this. I'll check it out (also gladly accepting pull requests :)

anttihirvonen commented 11 years ago

I can craft a patch for this – looks like a simple case, so should be finished quite quickly.