All you need to make this work is a library with your template file and a one line function in your library. Here’s a snippet from Displaying analytics data on site pages, where I have my template in a library file, as opposed to the project I’m working on.
In my library, I have this function
1 2 3 4 5 6 |
function getInstrumentationCode () { return HtmlService .createTemplateFromFile('instrumentationTemplate') .evaluate() .getContent(); } |
and an html template called ‘instrumentationTemplate’
Back in my main project I call it like this
1 2 3 4 |
// create the page return HtmlService .createTemplate(cSiteStats.getInstrumentationCode()) .evaluate(); |
Job done. Now I can use the same template across multiple templates.
For help and more information join our forum, follow the blog or follow me on Twitter