Using this for several pages. This example is a page for displaying users and CRUD.
Index page displays the user table and includes partials (modal, header).
modal.ejs has it’s own include which is the form to be rendered.
Both these partials are passed data on page load.
Header.ejs/Modal.ejs data. Works as intended.
<%- await include('/settings/partials/header', Object.assign({title: "Users",btnText: "Add User"}, locals)) %
>
<%- await include('/partials/modal', Object.assign({formPath:"/settings/users/partials/userForm"}, locals)) %>
modal.ejs hardcoded to perform create user.
<%- await include('/settings/users/partials/userForm', Object.assign({formAction: "/api/v1/user/create"}, locals)) %>
I would like to replace :
-
‘/settings/users/partials/userForm’ with a variable that allows me to use any form. <%=formPath %> holds that value but page breaks.
-
“/api/v1/user/create” with a variable to insert the api/sc call
Have tried with various methods resulting in either breaking the page or “breaking” the variable.value
Maybe it could be fixed with the correct escaping etc.
What is the formatting to insert {{variable}} or <%= variable =%> into the include strings without breaking the page ?
Last updated: