If I have only one file to include I could include it into the website and in the testing page, however I can’t do that because template is located on the same page where it is used.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should use some kind of module loader (AMD or CommonJS) to handle that. We are using requirejs using the text plugin to load text (any type of file in raw form template.tpl etc.) will work. And then just make your template a dependency for any module that can require it.
Also if your template engine of choice requires or supports precompiled templates you can create your own plugin for requirejs to compile the templates for you on the fly as they are required so you don’t have to do that manually.
Here is an example tutorial how to use it with Backbone
Embrace AMD/CommonJS and enjoy it!