> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/js/all/node/ejs.md).

# ejs

## Basics

`<% [code here] %>`

## Partials

Under the views/partials/ directory create a file called footer.ejs `<%- include('partials/footer') %>`

## IF

```javascript
 <% if (user) { %>
   <h2><%= user.name %></h2>
 <% } %>
```

## Loop

```javascript
<% users.forEach(function(user){ %>
    <%- include('user/show', {user: user}); %>
  <% });
%>
```

## Tags

<% 'Scriptlet' tag, for control-flow, no output <% *‘Whitespace Slurping’ Scriptlet tag, strips all whitespace before it <%= Outputs the value into the template (HTML escaped) <%- Outputs the unescaped value into the template <%# Comment tag, no execution, no output <%% Outputs a literal '<%' %> Plain ending tag -%> Trim-mode ('newline slurp') tag, trims following newline* %> ‘Whitespace Slurping’ ending tag, removes all whitespace after it
