Reputation: 2613
My footer HTML is in the file footer.ejs. On another page, I want to append this HTML dynamically with JavaScript.
The code below doesn't work. Is there a way to assign a template output to a JavaScript variable?
var footer = <%= include footer %>;
$('.test').after(footer);
The templates are rendered on the back-end (Node) and sent to front-end.
Upvotes: 1
Views: 126
Reputation: 2564
You probably need to enclose the tag in '
:
var footer = '<%= include footer %>';
Upvotes: 1