blueimp/JavaScript-Templates

Compiled template problem

Closed this issue · 3 comments

According to documentation, compiled my templates to external file:
tmpl.js templates/test/test.html > tmpl-templates.min.js

Documentation wrote: The generated file can be included in your project as a replacement for the original tmpl.js runtime. But this is not true - if I include only tmpl-templates.min.js, in same html page write new template with <script type="text/x-tmpl" id="new1">test</script>, I can't use tmpl("new1"), only templates, described in test.html. What I'm doing wrong? Including plain tmpl.min.js with tmpl-templates.min.js does not help. I think, compiled version must fill the templates cache and leave other template behavior unchanged.

If you still want to parse additional templates than you also still need the complete runtime.
Only if all your templates are precompiled will you not need the runtime.

But there is problem with 2 projects in one page...

2014-04-17 1:37 GMT+03:00 Sebastian Tschan notifications@github.com:

Closed #39 #39.


Reply to this email directly or view it on GitHubhttps://github.com//issues/39
.

I fixed this issue by editing runtime.js:45, namely changing $.tmpl = tmpl; to $.template = tmpl;. This allows me to compile tmpl.js with template rather than tmpl namespace. This way I can use both simultaneously.

That's a rather fugly solution, since I'm totally fucked when npm updates this package for me. An option to easily change the namespace when compiling via shell would be superb. Perhaps this could be done using a flag or something?
What if node_modules/.bin/tmpl.js --namespace template templates/* compiledTmpl.js ?