0
有沒有辦法讓你的HTML輸出來自一個Jade模板被美化?類似於Express的app.locals.pretty = true;
?如果相關,我正在使用koa-router
和koa-views
。與Koa漂亮的打印HTML輸出?
server.js
const koa = require('koa');
const views = require('koa-views');
const serve = require('koa-static');
const router = require('./routes');
const app = koa();
app.use(serve(`${__dirname}/public`));
app.use(views(`${__dirname}/views`, { extension: 'jade' }));
app.use(router.routes());
app.listen(3000,() => {
console.log('Server listening at http://localhost:3000');
});
路線/ index.js
const router = require('koa-router')();
router.get('/', function *() {
yield this.render('index');
});
module.exports = router;
的意見/ index.jade
html
head
title Hello
meta(charset='utf-8')
meta(name='viewport', content='width=device-width, initial-scale=1.0')
link(type='text/css', rel='stylesheet', href='css/style.css')
body
h1 Hi
不幸的是'KOA-views'沒有漂亮的選項:( 我想我必須嘗試koa玉,謝謝。 – saadq