Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinkjs/think-view-pug
Use pug to render view files for ThinkJS 3.x
https://github.com/thinkjs/think-view-pug
jade pug think-adapter view
Last synced: about 2 months ago
JSON representation
Use pug to render view files for ThinkJS 3.x
- Host: GitHub
- URL: https://github.com/thinkjs/think-view-pug
- Owner: thinkjs
- License: mit
- Created: 2017-03-10T11:15:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-02T00:12:06.000Z (over 3 years ago)
- Last Synced: 2024-12-16T08:49:11.214Z (2 months ago)
- Topics: jade, pug, think-adapter, view
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-view-pug
README
# think-view-pug
[![Build Status](https://travis-ci.org/thinkjs/think-view-pug.svg?branch=master)](https://travis-ci.org/thinkjs/think-view-pug)
[![Coverage Status](https://coveralls.io/repos/github/thinkjs/think-view-pug/badge.svg?branch=master)](https://coveralls.io/github/thinkjs/think-view-pug?branch=master)
[![npm](https://img.shields.io/npm/v/think-view-pug.svg?style=flat-square)](https://www.npmjs.com/package/think-view-pug)## Install
```
npm install think-view-pug
```## How to Usage
edit config file `src/config/adapter.js`, add options:
```js
const pug = require('think-view-pug');
exports.view = {
type: 'pug',
common: {
viewPath: path.join(think.ROOT_PATH, 'view'),
extname: '.html',
sep: '_' //seperator between controller and action
},
pug: {
handle: pug,
beforeRender: (pug, handleOptions) => {
// todo
}
}
}
```### default options
```js
const defaultOptions = {
cache: false,
debug: false
};
```
change options:```js
exports.view = {
type: 'pug',
pug: {
handle: pug,
options: {
cache: true,
self: true
},
beforeRender: (pug, handleOptions) => {
// todo
}
}
}
```
you can find all pug support options at https://pugjs.org/api/reference.html### beforeRender
you can use `beforeRender` method to enhance pug:
```js
exports.view = {
type: 'pug',
pug: {
handle: pug,
beforeRender: (pug, handleOptions) => {
pug.filters['my-own-filter'] = (text, options) => {
if (options.addStart) text = 'Start\n' + text;
if (options.addEnd) text = text + '\nEnd';
return text;
};
}
}
}
```
you can find all APIs at https://pugjs.org/api/reference.html