My objective is to have a page on which I would like to display some information via ejs in a specified div. There would be some buttons to change the way and/or the displayed information.
I've already created the button to display a dummy text. Now I would like to display some different template already stored as a string in my DB.
So I have this first ejs file, from where the user should be able to select another part of displayed code via some button. The buttons use a JS script to display the code with an .append(). I use
<%- JSON.stringify(stringOfCode)%>
to display my template. My problem is that the code is displayed within some quotation marks and that the ejs inside the stringOfCode is not working:
"
TEST TEMPLATE
Email Address : <%= user.email %>
First Name : <%= user.firstName %>
Last Name : <%= user.lastName %>
"
How can I solve this ? Or is there a better suited solution for what I want to do ?
EDIT
In my search of a solution, I've tried this :
I put the content of stringOfCode into a new ejs file called test0
In my script, I used this:
wrapper.append('<div class="container canvas" id="toCan"> Test 1 <%- include('test0'); %> </div>');
the result is that my button stopped working. I suppose this cause some kind of conflict when rendering the test0. Simply putting <%- include('test0'); %> works fine on its own, but that not what I'm aiming for