{ "name": "ejs", "description": "Embedded JavaScript templates", "keywords": [ "template", "engine", "ejs" ], "version": "2.3.4", "author": { "name": "Matthew Eernisse", "email": "mde@fleegix.org", "url": "http://fleegix.org" }, "contributors": [ { "name": "Timothy Gu", "email": "timothygu99@gmail.com", "url": "https://timothygu.github.io" } ], "license": "Apache-2.0", "main": "./lib/ejs.js", "repository": { "type": "git", "url": "git://github.com/mde/ejs.git" }, "bugs": { "url": "https://github.com/mde/ejs/issues" }, "homepage": "https://github.com/mde/ejs", "dependencies": {}, "devDependencies": { "browserify": "^8.0.3", "istanbul": "~0.3.5", "jake": "^8.0.0", "jsdoc": "^3.3.0-beta1", "lru-cache": "^2.5.0", "mocha": "^2.1.0", "rimraf": "^2.2.8", "uglify-js": "^2.4.16" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha", "coverage": "istanbul cover node_modules/mocha/bin/_mocha", "doc": "rimraf out && jsdoc -c jsdoc.json lib/* docs/jsdoc/*", "devdoc": "rimraf out && jsdoc -p -c jsdoc.json lib/* docs/jsdoc/*" }, "readme": "# EJS\n\nEmbedded JavaScript templates\n\n[![Build Status](https://img.shields.io/travis/mde/ejs/master.svg?style=flat)](https://travis-ci.org/mde/ejs)\n[![Developing Dependencies](https://img.shields.io/david/dev/mde/ejs.svg?style=flat)](https://david-dm.org/mde/ejs#info=devDependencies)\n\n## Installation\n\n```bash\n$ npm install ejs\n```\n\n## Features\n\n * Control flow with `<% %>`\n * Escaped output with `<%= %>`\n * Unescaped raw output with `<%- %>`\n * Trim-mode ('newline slurping') with `-%>` ending tag\n * Custom delimiters (e.g., use '' instead of '<% %>')\n * Includes\n * Client-side support\n * Static caching of intermediate JavaScript\n * Static caching of templates\n * Complies with the [Express](http://expressjs.com) view system\n\n## Example\n\n```html\n<% if (user) { %>\n

<%= user.name %>

\n<% } %>\n```\n\n## Usage\n\n```javascript\nvar template = ejs.compile(str, options);\ntemplate(data);\n// => Rendered HTML string\n\nejs.render(str, data, options);\n// => Rendered HTML string\n```\n\nYou can also use the shortcut `ejs.render(dataAndOptions);` where you pass\neverything in a single object. In that case, you'll end up with local variables\nfor all the passed options.\n\n## Options\n\n - `cache` Compiled functions are cached, requires `filename`\n - `filename` Used by `cache` to key caches, and for includes\n - `context` Function execution context\n - `compileDebug` When `false` no debug instrumentation is compiled\n - `client` Returns standalone compiled function\n - `delimiter` Character to use with angle brackets for open/close\n - `debug` Output generated function body\n - `_with` Whether or not to use `with() {}` constructs. If `false` then the locals will be stored in the `locals` object.\n - `rmWhitespace` Remove all safe-to-remove whitespace, including leading\n and trailing whitespace. It also enables a safer version of `-%>` line\n slurping for all scriptlet tags (it does not strip new lines of tags in\n the middle of a line).\n\n## Tags\n\n - `<%` 'Scriptlet' tag, for control-flow, no output\n - `<%=` Outputs the value into the template (HTML escaped)\n - `<%-` Outputs the unescaped value into the template\n - `<%#` Comment tag, no execution, no output\n - `<%%` Outputs a literal '<%'\n - `%>` Plain ending tag\n - `-%>` Trim-mode ('newline slurp') tag, trims following newline\n\n## Includes\n\nIncludes either have to be an absolute path, or, if not, are assumed as\nrelative to the template with the `include` call. (This requires the\n`filename` option.) For example if you are including `./views/user/show.ejs`\nfrom `./views/users.ejs` you would use `<%- include('user/show') %>`.\n\nYou'll likely want to use the raw output tag (`<%-`) with your include to avoid\ndouble-escaping the HTML output.\n\n```html\n\n```\n\nIncludes are inserted at runtime, so you can use variables for the path in the\n`include` call (for example `<%- include(somePath) %>`). Variables in your\ntop-level data object are available to all your includes, but local variables\nneed to be passed down.\n\nNOTE: Include preprocessor directives (`<% include user/show %>`) are\nstill supported.\n\n## Custom delimiters\n\nCustom delimiters can be applied on a per-template basis, or globally:\n\n```javascript\nvar ejs = require('ejs'),\n users = ['geddy', 'neil', 'alex'];\n\n// Just one template\nejs.render('', {users: users}, {delimiter: '?'});\n// => 'geddy | neil | alex'\n\n// Or globally\nejs.delimiter = '$';\nejs.render('<$= users.join(\" | \"); $>', {users: users});\n// => 'geddy | neil | alex'\n```\n\n## Caching\n\nEJS ships with a basic in-process cache for caching the intermediate JavaScript\nfunctions used to render templates. It's easy to plug in LRU caching using\nNode's `lru-cache` library:\n\n```javascript\nvar ejs = require('ejs')\n , LRU = require('lru-cache');\nejs.cache = LRU(100); // LRU cache with 100-item limit\n```\n\nIf you want to clear the EJS cache, call `ejs.clearCache`. If you're using the\nLRU cache and need a different limit, simple reset `ejs.cache` to a new instance\nof the LRU.\n\n## Layouts\n\nEJS does not specifically support blocks, but layouts can be implemented by\nincluding headers and footers, like so:\n\n\n```html\n<%- include('header') -%>\n

\n Title\n

\n

\n My page\n

\n<%- include('footer') -%>\n```\n\n## Client-side support\n\nGo to the [Latest Release](https://github.com/mde/ejs/releases/latest), download\n`./ejs.js` or `./ejs.min.js`.\n\nInclude one of these on your page, and `ejs.render(str)`.\n\n## Related projects\n\nThere are a number of implementations of EJS:\n\n * TJ's implementation, the v1 of this library: https://github.com/tj/ejs\n * Jupiter Consulting's EJS: http://www.embeddedjs.com/\n * EJS Embedded JavaScript Framework on Google Code: https://code.google.com/p/embeddedjavascript/\n * Sam Stephenson's Ruby implementation: https://rubygems.org/gems/ejs\n * Erubis, an ERB implementation which also runs JavaScript: http://www.kuwata-lab.com/erubis/users-guide.04.html#lang-javascript\n\n## License\n\nLicensed under the Apache License, Version 2.0\n()\n\n- - -\nEJS Embedded JavaScript templates copyright 2112\nmde@fleegix.org.\n\n\n", "readmeFilename": "README.md", "_id": "ejs@2.3.4", "dist": { "shasum": "f23675dcdcda36d7337cfada2e2303d01e596238" }, "_from": "ejs@>= 0.0.1", "_resolved": "https://registry.npmjs.org/ejs/-/ejs-2.3.4.tgz" }