1.0.9 • Published 3 years ago

think-view-pug v1.0.9

Weekly downloads
1
License
ISC
Repository
github
Last release
3 years ago

think-view-pug

Build Status Coverage Status npm

Install

npm install think-view-pug

How to Usage

edit config file src/config/adapter.js, add options:

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

const defaultOptions = {
  cache: false,
  debug: false
};

change options:

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:

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

1.0.9

3 years ago

1.0.8

4 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago