tj / co-views

Higher-level template rendering for node.js using generators
173 stars 24 forks source link

Trouble changing templating engine #11

Closed dadambickford closed 10 years ago

dadambickford commented 10 years ago

Here is my server.js

var logger = require('koa-logger');
var route = require('koa-route');
var views = require('co-views');
var koa = require('koa');

app = koa();

app.use(logger());

app.use(route.get('/', index));
app.use(route.get('/about', about));

var render = views(__dirname + '/views', { map: { html: 'swig' }});

function *index() {
  this.body = yield render('index');
}

function *about() {
  this.body = yield render('about');
}

app.listen(3000);
console.log("App is now running at localhost:3000");

My trouble seems to come on line 13

var render = views(__dirname + '/views', { map: { html: 'swig' }});

I don't want to use any templating engine, or if I have to I'd prefer handlebars. The docs say that the default template extension is html, but if I remove that { map: { html: 'swig' }} I just get 500 errors. I've tried passing in { map: { html: 'html' }}, removing map and passing in default: 'html', just passing in an empty object, and can't seem to figure out how to just use nothing. Everything I've tried gives me a 500 error, but it works perfectly as intended with { map: { html: 'swig' }} included. Thanks for your help.

tj commented 10 years ago

if you dont want any engine just serve static files

tj commented 10 years ago

with "send" (in the koa wiki) or a static file middleware ("static")