Reusability and passing data to ejs includes/partials

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 :

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 ?

Community Page
Last updated: