Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisyip/egg-view-pug
egg view plugin for pug.
https://github.com/chrisyip/egg-view-pug
egg egg-plugin egg-view pug
Last synced: 3 months ago
JSON representation
egg view plugin for pug.
- Host: GitHub
- URL: https://github.com/chrisyip/egg-view-pug
- Owner: chrisyip
- License: mit
- Created: 2017-02-27T04:07:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T06:56:10.000Z (almost 4 years ago)
- Last Synced: 2024-10-11T23:09:26.416Z (4 months ago)
- Topics: egg, egg-plugin, egg-view, pug
- Language: JavaScript
- Size: 181 KB
- Stars: 24
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# egg-view-pug
[![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url]
egg view plugin for [pug](https://pugjs.org/).
**V2 supports pug v3 and therefore [requires node >= 10](https://pugjs.org/api/migration-v3.html)**.
## Install
```
npm i egg-view-pug --save
```## Usage
```js
// {app_root}/config/plugin.js
exports.pug = {
enable: true,
package: 'egg-view-pug'
}// {app_root}/config/config.default.js
exports.view = {
mapping: {
'.pug': 'pug',
}
}// configuration
exports.pug = {}
```Create a pug file
```pug
//- app/view/hello.pugextend layout/main
block header
include partial/headerblock content
| hello #{data}
```Render it
```js
// app/controller/CONTROLLER.js
exports = {
async ACTION (ctx) {
await ctx.render('hello.pug', {
data: 'world'
})
}
}
```The file will be compiled and cached, you can change `config.pug.cache = false` to disable cache, it's disable in local env by default.
## Configuration
see [config/config.default.js](config/config.default.js) for more detail.
[npm-url]: https://npmjs.org/package/egg-view-pug
[npm-image]: http://img.shields.io/npm/v/egg-view-pug.svg?style=flat-square
[daviddm-url]: https://david-dm.org/chrisyip/egg-view-pug
[daviddm-image]: http://img.shields.io/david/chrisyip/egg-view-pug.svg?style=flat-square
[travis-url]: https://travis-ci.org/chrisyip/egg-view-pug
[travis-image]: http://img.shields.io/travis/chrisyip/egg-view-pug.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/chrisyip/egg-view-pug
[codecov-image]: https://img.shields.io/codecov/c/github/chrisyip/egg-view-pug.svg?style=flat-square