├── .eslintignore ├── .eslintrc ├── test ├── fixtures │ └── apps │ │ └── ejs-view │ │ ├── app │ │ ├── view │ │ │ ├── error.ejs │ │ │ ├── ejs.html │ │ │ ├── included.ejs │ │ │ ├── include │ │ │ │ ├── footer.ejs │ │ │ │ ├── header.ejs │ │ │ │ └── index.ejs │ │ │ ├── locals.ejs │ │ │ ├── helper.ejs │ │ │ └── layout.html │ │ ├── extend │ │ │ ├── helper.js │ │ │ ├── context.js │ │ │ └── application.js │ │ ├── router.js │ │ └── controller │ │ │ └── view.js │ │ ├── package.json │ │ └── config │ │ └── config.default.js └── ejs.test.js ├── config ├── config.local.js └── config.default.js ├── app.js ├── .gitignore ├── .autod.conf.js ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── nodejs.yml ├── LICENSE ├── lib └── view.js ├── package.json ├── History.md └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-egg" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/error.ejs: -------------------------------------------------------------------------------- 1 | <% a 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/ejs.html: -------------------------------------------------------------------------------- 1 | hello world 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/included.ejs: -------------------------------------------------------------------------------- 1 | world 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/include/footer.ejs: -------------------------------------------------------------------------------- 1 | footer 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/include/header.ejs: -------------------------------------------------------------------------------- 1 | header 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/locals.ejs: -------------------------------------------------------------------------------- 1 | hello <%= data %> 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/helper.ejs: -------------------------------------------------------------------------------- 1 | hello <%= helper.data() %> 2 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/layout.html: -------------------------------------------------------------------------------- 1 | in layout 2 | <%-body%> 3 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ejs-view" 3 | } 4 | -------------------------------------------------------------------------------- /config/config.local.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.ejs = { 4 | cache: false, 5 | }; 6 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = app => { 4 | app.view.use('ejs', require('./lib/view')); 5 | }; 6 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/extend/helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.data = () => { 4 | return 'world'; 5 | }; 6 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/extend/context.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('egg-view/app/extend/context'); 4 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/view/include/index.ejs: -------------------------------------------------------------------------------- 1 | hello <%- include('header.ejs') %> 2 | hello <%- include('/include/footer.ejs') %> -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/extend/application.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('egg-view/app/extend/application'); 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | npm-debug.log 3 | node_modules/ 4 | coverage/ 5 | .idea/ 6 | run/ 7 | .DS_Store 8 | *.swp 9 | 10 | test/fixtures/apps/ejs-view/app/view/cache.ejs 11 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/config/config.default.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.keys = '123'; 4 | exports.view = { 5 | defaultViewEngine: 'ejs', 6 | mapping: { 7 | '.ejs': 'ejs', 8 | '.html': 'ejs', 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /.autod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | write: true, 5 | prefix: '^', 6 | test: [ 7 | 'test', 8 | 'benchmark', 9 | ], 10 | devdep: [ 11 | 'egg-ci', 12 | 'egg-bin', 13 | 'autod', 14 | 'eslint', 15 | 'eslint-config-egg', 16 | ], 17 | exclude: [ 18 | './test/fixtures', 19 | './docs', 20 | './coverage', 21 | ], 22 | registry: 'https://r.cnpmjs.org', 23 | }; 24 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/router.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = app => { 4 | app.get('/locals', 'view.renderWithLocals'); 5 | app.get('/include', 'view.include'); 6 | app.get('/cache', 'view.cache'); 7 | app.get('/helper', 'view.renderWithHelper'); 8 | app.get('/htmlext', 'view.htmlext'); 9 | app.get('/error', 'view.error'); 10 | app.get('/render-string', 'view.renderStringWithData'); 11 | app.get('/render-string-helper', 'view.renderStringWithHelper'); 12 | app.get('/render-string-error', 'view.renderStringError'); 13 | app.get('/render-layout', 'view.renderWithLayout'); 14 | }; 15 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ##### Checklist 12 | 13 | 14 | - [ ] `npm test` passes 15 | - [ ] tests and/or benchmarks are included 16 | - [ ] documentation is changed or added 17 | - [ ] commit message follows commit guidelines 18 | 19 | ##### Affected core subsystem(s) 20 | 21 | 22 | 23 | ##### Description of change 24 | 25 | -------------------------------------------------------------------------------- /config/config.default.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | module.exports = appInfo => { 6 | return { 7 | /** 8 | * @member Config#ejs 9 | * @property {String} [root=${baseDir}/app/view] - the root directory of ejs files 10 | * @property {Boolean} [cache=true] - compiled functions are cached, only work using `ctx.render` 11 | * @property {Boolean} [debug=false] - output generated function body 12 | * @property {Boolean} [compileDebug=true] - when false no debug instrumentation is compiled 13 | * @property {String} [delimiter] - character to use with angle brackets for open/close 14 | * @property {Boolean} [strict=false] - when set to true, generated function is in strict mode 15 | */ 16 | ejs: { 17 | root: path.join(appInfo.baseDir, 'app/view'), 18 | cache: true, 19 | debug: false, 20 | compileDebug: true, 21 | delimiter: null, 22 | strict: false, 23 | }, 24 | }; 25 | }; 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Alibaba Group Holding Limited and other contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: 9 | - main 10 | - master 11 | pull_request: 12 | branches: 13 | - main 14 | - master 15 | schedule: 16 | - cron: '0 2 * * *' 17 | 18 | jobs: 19 | build: 20 | runs-on: ${{ matrix.os }} 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | node-version: [14, 16] 26 | os: [ubuntu-latest, windows-latest, macos-latest] 27 | 28 | steps: 29 | - name: Checkout Git Source 30 | uses: actions/checkout@v2 31 | 32 | - name: Use Node.js ${{ matrix.node-version }} 33 | uses: actions/setup-node@v1 34 | with: 35 | node-version: ${{ matrix.node-version }} 36 | 37 | - name: Install Dependencies 38 | run: npm i 39 | 40 | - name: Continuous Integration 41 | run: npm run ci 42 | 43 | - name: Code Coverage 44 | uses: codecov/codecov-action@v1 45 | with: 46 | token: ${{ secrets.CODECOV_TOKEN }} 47 | -------------------------------------------------------------------------------- /lib/view.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const ejs = require('ejs'); 4 | const RENDER = Symbol('EjsView#_render'); 5 | 6 | module.exports = class EjsView { 7 | 8 | constructor(ctx) { 9 | this.ctx = ctx; 10 | this.app = ctx.app; 11 | this.config = ctx.app.config.ejs; 12 | } 13 | 14 | [RENDER](filename, locals, config) { 15 | return new Promise((resolve, reject) => { 16 | ejs.renderFile(filename, locals, config, (err, result) => { 17 | if (err) { 18 | reject(err); 19 | } else { 20 | resolve(result); 21 | } 22 | }); 23 | }); 24 | } 25 | 26 | async render(filename, locals, viewOptions) { 27 | const config = Object.assign({}, this.config, viewOptions, { filename }); 28 | const html = await this[RENDER](filename, locals, config); 29 | if (!config.layout) { 30 | return html; 31 | } 32 | 33 | locals.body = html; 34 | const layout = await this.app.view.resolve(config.layout); 35 | return await this[RENDER](layout, locals, config); 36 | } 37 | 38 | async renderString(tpl, locals, viewOptions) { 39 | // should disable cache when no filename 40 | const config = Object.assign({}, this.config, viewOptions, { cache: null }); 41 | return ejs.render(tpl, locals, config); 42 | } 43 | }; 44 | -------------------------------------------------------------------------------- /test/fixtures/apps/ejs-view/app/controller/view.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.renderWithLocals = function* (ctx) { 4 | yield ctx.render('locals.ejs', { 5 | data: 'world', 6 | }); 7 | }; 8 | 9 | exports.include = function* (ctx) { 10 | yield ctx.render('include/index.ejs'); 11 | }; 12 | 13 | exports.renderWithHelper = function* (ctx) { 14 | yield ctx.render('helper.ejs'); 15 | }; 16 | 17 | exports.cache = function* (ctx) { 18 | yield ctx.render('cache.ejs'); 19 | }; 20 | 21 | exports.htmlext = function* (ctx) { 22 | yield ctx.render('ejs.html'); 23 | }; 24 | 25 | exports.error = function* (ctx) { 26 | try { 27 | yield ctx.render('error.ejs'); 28 | } catch (err) { 29 | this.body = err.message; 30 | } 31 | }; 32 | 33 | exports.renderStringWithData = function* (ctx) { 34 | ctx.body = yield ctx.renderString('hello <%= data %>', { 35 | data: 'world', 36 | }); 37 | }; 38 | 39 | exports.renderStringWithHelper = function* (ctx) { 40 | ctx.body = yield ctx.renderString('hello <%= helper.data() %>'); 41 | }; 42 | 43 | exports.renderStringError = function* (ctx) { 44 | try { 45 | yield ctx.renderString('<% a'); 46 | } catch (err) { 47 | ctx.body = err.message; 48 | } 49 | }; 50 | 51 | exports.renderWithLayout = function* (ctx) { 52 | yield ctx.render('ejs.html', {}, { 53 | layout: 'layout.html', 54 | }); 55 | }; 56 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "egg-view-ejs", 3 | "version": "3.0.0", 4 | "description": "egg view plugin for ejs", 5 | "eggPlugin": { 6 | "name": "ejs", 7 | "dependencies": [ 8 | "view" 9 | ] 10 | }, 11 | "keywords": [ 12 | "egg", 13 | "eggPlugin", 14 | "egg-plugin", 15 | "egg-view", 16 | "ejs" 17 | ], 18 | "dependencies": { 19 | "ejs": "^3" 20 | }, 21 | "devDependencies": { 22 | "autod": "^3", 23 | "egg": "^2", 24 | "egg-bin": "^4", 25 | "egg-ci": "^2", 26 | "egg-mock": "^4", 27 | "eslint": "^8", 28 | "eslint-config-egg": "^12" 29 | }, 30 | "engines": { 31 | "node": ">=14.0.0" 32 | }, 33 | "scripts": { 34 | "test": "npm run lint -- --fix && npm run test-local", 35 | "test-local": "egg-bin test", 36 | "cov": "egg-bin cov", 37 | "lint": "eslint .", 38 | "ci": "npm run lint && npm run cov", 39 | "autod": "autod" 40 | }, 41 | "files": [ 42 | "config", 43 | "app", 44 | "lib", 45 | "app.js" 46 | ], 47 | "ci": { 48 | "version": "14, 16", 49 | "type": "github" 50 | }, 51 | "repository": { 52 | "type": "git", 53 | "url": "git+https://github.com/eggjs/egg-view-ejs.git" 54 | }, 55 | "bugs": { 56 | "url": "https://github.com/eggjs/egg/issues" 57 | }, 58 | "homepage": "https://github.com/eggjs/egg-view-ejs#readme", 59 | "author": "popomore ", 60 | "license": "MIT" 61 | } 62 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 3.0.0 / 2022-06-29 3 | ================== 4 | 5 | **others** 6 | * [[`22ec14d`](http://github.com/eggjs/egg-view-ejs/commit/22ec14deeb2752814b1522bd44d773025c51d0b3)] - deps: update to 14.x (#14) (TZ | 天猪 <>) 7 | * [[`0c89549`](http://github.com/eggjs/egg-view-ejs/commit/0c895495791f8a1b500387a6c3178f973b09796c)] - [BREAK_CHANGE] feat: update ejs@3 (#13) (En Yang Du <<377153400@qq.com>>) 8 | 9 | 2.0.1 / 2020-02-03 10 | ================== 11 | 12 | **others** 13 | * [[`5b4e4d0`](http://github.com/eggjs/egg-view-ejs/commit/5b4e4d0dac54a7a3046a5370dc0db160637aae46)] - chore: update deps (#11) (TZ | 天猪 <>) 14 | * [[`69a80b2`](http://github.com/eggjs/egg-view-ejs/commit/69a80b25a21072fd6fa3fdf9468490268525ebbb)] - chore: fix typo (#9) (sinchang <>) 15 | 16 | 2.0.0 / 2017-11-15 17 | ================== 18 | 19 | **others** 20 | * [[`05e708e`](http://github.com/eggjs/egg-view-ejs/commit/05e708e4f02897e3dc61d4fc2b8fe675f99f3331)] - refactor: use async function and support egg@2 (#8) (Yiyu He <>) 21 | * [[`e8e497d`](http://github.com/eggjs/egg-view-ejs/commit/e8e497d83f63384390053ee9baf06c96c3f8eec1)] - docs: Update README.md (#7) (Runrioter Wung <>) 22 | 23 | 1.1.0 / 2017-03-27 24 | ================== 25 | 26 | * feat: add layout (#6) 27 | * docs: can't overrite default `view` plugin (#5) 28 | 29 | 1.0.1 / 2017-02-23 30 | ================== 31 | 32 | * fix: missing app.js in pkg.files 33 | 34 | 1.0.0 / 2017-02-03 35 | ================== 36 | 37 | * init version 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # egg-view-ejs 2 | 3 | [![NPM version](https://img.shields.io/npm/v/egg-view-ejs.svg?style=flat-square)](https://npmjs.org/package/egg-view-ejs) 4 | [![NPM quality](http://npm.packagequality.com/shield/egg-view-ejs.svg?style=flat-square)](http://packagequality.com/#?package=egg-view-ejs) 5 | [![NPM download](https://img.shields.io/npm/dm/egg-view-ejs.svg?style=flat-square)](https://npmjs.org/package/egg-view-ejs) 6 | 7 | [![Continuous Integration](https://github.com/eggjs/egg-view-ejs/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-view-ejs/actions/workflows/nodejs.yml) 8 | [![Test coverage](https://img.shields.io/codecov/c/github/eggjs/egg-view-ejs.svg?style=flat-square)](https://codecov.io/gh/eggjs/egg-view-ejs) 9 | 10 | 11 | egg view plugin for [ejs]. 12 | 13 | ## Install 14 | 15 | ```bash 16 | $ npm i egg-view-ejs --save 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```js 22 | // {app_root}/config/plugin.js 23 | exports.ejs = { 24 | enable: true, 25 | package: 'egg-view-ejs', 26 | }; 27 | 28 | // {app_root}/config/config.default.js 29 | exports.view = { 30 | mapping: { 31 | '.ejs': 'ejs', 32 | }, 33 | }; 34 | ``` 35 | 36 | Create a ejs file 37 | 38 | ```js 39 | // app/view/hello.ejs 40 | hello <%= data %> 41 | ``` 42 | 43 | Render it 44 | 45 | ```js 46 | // app/controller/render.js 47 | exports.ejs = async ctx => { 48 | await ctx.render('hello.ejs', { 49 | data: 'world', 50 | }); 51 | }; 52 | ``` 53 | 54 | The file will be compiled and cached, you can change `config.ejs.cache = false` to disable cache, it's disable in local env by default. 55 | 56 | ### Include 57 | 58 | You can include both relative and absolute file. 59 | 60 | Relative file is resolve from current file path. 61 | 62 | ```html 63 | // app/view/a.ejs include app/view/b.ejs 64 | <% include('b.ejs') %> 65 | ``` 66 | 67 | Absolute file is resolve from `app/view`. 68 | 69 | ```html 70 | // app/view/home.ejs include app/view/partial/menu.ejs 71 | <% include('/partial/menu.ejs') %> 72 | ``` 73 | 74 | ### Layout 75 | 76 | You can render a view with layout also: 77 | 78 | ```js 79 | // app/view/layout.ejs 80 | 81 | <% body %> 82 | 83 | // app/controller/render.js 84 | exports.ejs = async ctx => { 85 | const locals = { 86 | data: 'world', 87 | }; 88 | 89 | const viewOptions = { 90 | layout: 'layout.ejs' 91 | }; 92 | 93 | await ctx.render('hello.ejs', locals, viewOptions); 94 | }; 95 | ``` 96 | 97 | ## Configuration 98 | 99 | see [config/config.default.js](config/config.default.js) for more detail. 100 | 101 | ## Questions & Suggestions 102 | 103 | Please open an issue [here](https://github.com/eggjs/egg/issues). 104 | 105 | ## License 106 | 107 | [MIT](LICENSE) 108 | 109 | [ejs]: https://github.com/mde/ejs 110 | -------------------------------------------------------------------------------- /test/ejs.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const mm = require('egg-mock'); 5 | const fs = require('fs').promises; 6 | 7 | const fixtures = path.join(__dirname, 'fixtures'); 8 | 9 | 10 | describe('test/egg-view-ejs.test.js', () => { 11 | 12 | describe('render', () => { 13 | let app; 14 | before(() => { 15 | app = mm.app({ 16 | baseDir: 'apps/ejs-view', 17 | }); 18 | return app.ready(); 19 | }); 20 | after(() => app.close()); 21 | 22 | it('should render with locals', () => { 23 | return app.httpRequest() 24 | .get('/locals') 25 | .expect(/hello world\r?\n/) 26 | .expect(200); 27 | }); 28 | 29 | it('should render with include', () => { 30 | return app.httpRequest() 31 | .get('/include') 32 | .expect(/hello header\r?\n\r?\nhello footer\r?\n/) 33 | .expect(200); 34 | }); 35 | 36 | it('should render with helper', () => { 37 | return app.httpRequest() 38 | .get('/helper') 39 | .expect(/hello world\r?\n/) 40 | .expect(200); 41 | }); 42 | 43 | it('should render with cache', async () => { 44 | const cacheFile = path.join(fixtures, 'apps/ejs-view/app/view/cache.ejs'); 45 | await fs.writeFile(cacheFile, '1'); 46 | await app.httpRequest() 47 | .get('/cache') 48 | .expect('1') 49 | .expect(200); 50 | 51 | await fs.writeFile(cacheFile, '2'); 52 | await app.httpRequest() 53 | .get('/cache') 54 | .expect('1') 55 | .expect(200); 56 | }); 57 | 58 | it('should render with html extension', () => { 59 | return app.httpRequest() 60 | .get('/htmlext') 61 | .expect(/hello world\r?\n/) 62 | .expect(200); 63 | }); 64 | 65 | it('should render with layout', () => { 66 | return app.httpRequest() 67 | .get('/render-layout') 68 | .expect(/in layout\r?\nhello world\r?\n\r?\n/) 69 | .expect(200); 70 | }); 71 | 72 | it('should render error', () => { 73 | return app.httpRequest() 74 | .get('/error') 75 | .expect('Could not find matching close tag for "<%".') 76 | .expect(200); 77 | }); 78 | }); 79 | 80 | describe('renderString', () => { 81 | let app; 82 | before(() => { 83 | app = mm.app({ 84 | baseDir: 'apps/ejs-view', 85 | }); 86 | return app.ready(); 87 | }); 88 | after(() => app.close()); 89 | 90 | it('should renderString with data', () => { 91 | return app.httpRequest() 92 | .get('/render-string') 93 | .expect('hello world') 94 | .expect(200); 95 | }); 96 | 97 | it('should renderString with helper', () => { 98 | return app.httpRequest() 99 | .get('/render-string-helper') 100 | .expect('hello world') 101 | .expect(200); 102 | }); 103 | 104 | it('should renderString error', () => { 105 | return app.httpRequest() 106 | .get('/render-string-error') 107 | .expect('Could not find matching close tag for "<%".') 108 | .expect(200); 109 | }); 110 | }); 111 | 112 | describe('no cache', () => { 113 | let app; 114 | before(() => { 115 | mm.env('local'); 116 | app = mm.app({ 117 | baseDir: 'apps/ejs-view', 118 | }); 119 | return app.ready(); 120 | }); 121 | after(() => app.close()); 122 | 123 | it('should render without cache', async () => { 124 | const cacheFile = path.join(fixtures, 'apps/ejs-view/app/view/cache.ejs'); 125 | await fs.writeFile(cacheFile, '1'); 126 | await app.httpRequest() 127 | .get('/cache') 128 | .expect('1') 129 | .expect(200); 130 | 131 | await fs.writeFile(cacheFile, '2'); 132 | await app.httpRequest() 133 | .get('/cache') 134 | .expect('2') 135 | .expect(200); 136 | }); 137 | }); 138 | }); 139 | --------------------------------------------------------------------------------