EJS 6
Last reviewed Sep 19, 2026
Prompt Details
Prompt Composition
3prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Node.js 24101 lines · 5.3K tokens
- EJS 651 lines · 1.9K tokens
Total254 lines · 10.3K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 88
- 89
- 95
- 113
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 297
- 319
- 323
- 330
- 338
- 346
- 347
- 352
- 354
- 362
- 367
- 377
- 426
- 444
- 459
- 471
- 488
- 494
- 502
- 524
- 532
- 602
- 653
- 732
- 770
- 807
- 829
- 838
- 862
- 863
- 908
- 916
- 918
- 922
- 942
- 943
- 1004
- 1321
- 1333
Prompt Preview
Apply the Node.js 24 prompt first. These rules target EJS 6 on Node.js 24 and were checked against 6.0.1; apply the browser-delivery rule when shipping EJS to clients.
Template and option authority
- Treat templates passed to
ejs.compile()orejs.render()and files loaded byejs.renderFile(), including loader-produced partials, as application code. Never compile user-authored content or recompile rendered output, even after HTML sanitization. - Supply a separate, developer-owned options object to
ejs.render(template, viewModel, options)andejs.renderFile(filename, viewModel, options[, callback]). The two-argumentrender()form andrenderFile()without explicit options promote selected data properties into engine options. - Construct locals from explicitly selected fields; never pass
req.query,req.body, or an unrestricted spread of input directly to a rendering API. Keep compiler settings, callbacks, and delimiter choices outside the user-controlled view model. - Keep Express
settings,settings['view options'], and option-bearingapp.locals,res.locals, and render locals server-owned. EJS reads view paths and caching from settings, copies view options, and then lets recognized top-level locals override them. Use anapp.engine()adapter that callsejs.renderFile(path, data, trustedOptions, callback)when options must be independent of these locals.
Locals and execution context
- Keep
unsafePrototypeLocals: false, the v6 default. EJS copies own enumerable locals to an object without a prototype; project required class properties