Skip to content

chrisyip/egg-view-pug

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

egg-view-pug

NPM version Dependency Status Travis CI codecov

egg view plugin for pug.

V2 supports pug v3 and therefore requires node >= 10.

Install

npm i egg-view-pug --save

Usage

// {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

//- app/view/hello.pug

extend layout/main

block header
  include partial/header

block content
  | hello #{data}

Render it

// 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 for more detail.

About

egg view plugin for pug.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published