Handlebars.js in Django templates

前端 未结 8 1563

I need a javascript templating system and i think handlebars.js does an excellent job in this case. I\'m having syntax conflicts with handlebars templates inside a django te

8条回答
  •  时光取名叫无心
    2020-12-24 06:36

    Compile your handlebars first!

    From handlebars precompiling documentation:

    In addition to reducing the download size, eliminating client-side compilation will significantly speed up boot time, as compilation is the most expensive part of Handlebars.

    You can compile templates in your build environment using handlebars npm module, or integrate it with a build tool like gulp with gulp-handlebars.

    After compiling, your handlebars templates can be served as static resources and bypass server side rendering altogether. Makes it easier on caching too :)

    Typical usage would look like this:

    Waiting for content...

提交回复
热议问题