Giter VIP home page Giter VIP logo

Comments (4)

i5ting avatar i5ting commented on May 12, 2024

@luchanan 开一个repo写个demo,然后给我

from koa-generator.

luchanan avatar luchanan commented on May 12, 2024

这个问题demo: https://github.com/luchanan/koa2_hbs.git
其实我看了express-generator,他们用的hbs,已经对handlebars进行了高级封装吧,有继承layout的功能。然后我看了你这里只有handlebars这个东西,我在想是不是基础版,layout需要自己实现(如上面我改的)。后来我用了koa-hbs(支持koa2)来弄就可以了,解决了刷新报错的问题。因为我看koa-views参数比较少,koa-hbs的参数好像不能用在koa-views上,所以我进行了下面的修改

// app.js
const hbs = require('koa-hbs')
...
// app.use(views(__dirname + '/views', {
//   extension: 'hbs',
//   map: { hbs: 'handlebars' },
//     defaultLayout: 'layout'
// }))

app.use(hbs.middleware({
    viewPath: __dirname + '/views',
    layoutsPath: __dirname + '/views',
}));
// index.hbs
{{!< layout }}
<h1>{{title}}</h1>
<p>Welcome to {{title}}</p>

请求高见

from koa-generator.

jane- avatar jane- commented on May 12, 2024

我安装啦 npm install -g koa-generator 之后 运行 koa koa2 && cd koa2 然后报错 koa: command not found ,我的是mac系统 node v8.2.1版本

from koa-generator.

i5ting avatar i5ting commented on May 12, 2024

@jane- 很奇怪啊,有更多信息么?

from koa-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.