0

I need a client-side javascript template engine that supports loading partials from files. That's because I have a template with an unordered list. It has 2 types of list items (that means, for example, one li tag has a text input while another one has a text input and an image).

I now want to be able to use these list item templates in different template files without having to copy/paste them.

I used doT.js partials until now, but to be able to use a partial, it has to be declared in the same file. Therefore, I had to copy the snippets to each template file and when I made a change to how one of the li templates was structured, I had to change it in all files.

I want to avoid that. Is there anything I could use?

I'm planning on using the template with a require.js plugin if available.

Manuel Hoffmann
  • 539
  • 1
  • 7
  • 23
  • In [handlebars](http://handlebarsjs.com/) you can register partials out of different files, but you also need to define them before you _execute_ the template. I hope that is what you are looking for. – t.niese Apr 15 '14 at 10:13
  • How would the syntax be? – Manuel Hoffmann Apr 15 '14 at 10:38
  • Sorry i don't have time to write a full answer right now [Handlebars: Partials](https://github.com/wycats/handlebars.js/#partials) – t.niese Apr 15 '14 at 10:45

0 Answers0