在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ladjs/cache-pug-templates开源软件地址:https://github.com/ladjs/cache-pug-templates开源编程语言:JavaScript 100.0%开源软件介绍:cache-pug-templatesTable of ContentsInstallnpm: npm install cache-pug-templates yarn: yarn add cache-pug-templates UsageBasicconst path = require('path');
const CachePugTemplates = require('cache-pug-templates');
const views = path.join(__dirname, 'views');
const cache = new CachePugTemplates({ views });
cache.start(); Koaconst path = require('path');
const Koa = require('koa');
const CachePugTemplates = require('cache-pug-templates');
const app = new Koa();
// optional (e.g. if you want to cache in non-production)
// app.cache = true;
// note that koa requires us to specify a
// path name for the views directory
const views = path.join(__dirname, 'views');
app.listen(3000, () => {
const cache = new CachePugTemplates({ app, views });
cache.start();
}); Expressconst path = require('path');
const express = require('express');
const CachePugTemplates = require('cache-pug-templates');
const app = express();
// optional (by default express defaults to `./views`)
// app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.listen(3000, () => {
const cache = new CachePugTemplates({ app, views });
cache.start();
}); Options
DebuggingIf you want to check what the cache state is at anytime: const pug = require('pug');
// ...
// get everything:
console.log('pug.cache', pug.cache);
// just get the file names:
console.log('pug cached files', Object.keys(pug.cache)); Contributors
License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论