Deniz Ozger
Deniz Ozger

Reputation: 2613

Assign output of EJS include tag to a JavaScript variable

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

Answers (1)

ralh
ralh

Reputation: 2564

You probably need to enclose the tag in ':

var footer = '<%= include footer %>';

Upvotes: 1

Related Questions