我创建这个模板:node.js的EJS包括错误
<% include head %>
<Placemark>
<name><%=name%></name>
<description><%=description%></description>
<Point>
<coordinates><%=coordinates%></coordinates>
</Point>
</Placemark>
<% include foot %>
但我总是得到这样的错误:
if (!filename) throw new Error('filename option is required for includ
^
目录:
[email protected]:~/node-socket.io/socket.io/examples/kml$ ls -1
app.js
foot.ejs
head.ejs
placemark.ejs
能
别人的帮助,我根据工具箱的一切应该工作
个app.js:
var http = require('http');
var ejs = require('ejs');
var fs = require('fs')
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/xml'});
fs.readFile('placemark.ejs', 'utf8', function (err, template) {
var content = ejs.render(template,{
name:"test name",
description:"this is the description",
coordinates:"-122.0822035425683,37.42228990140251,0"
});
res.write(content);
res.end()
});
}).listen(8000);
console.log('Server listening at at xxxxxxxx');
使用EJS我呈现模板,从其他模板构建。使用ejs-locals它说它没有方法渲染。有没有办法只用'ejs'来做到这一点?
什么版本你正在使用ejs和express吗?这看起来是正确的,是我使用的。 https://github.com/visionmedia/ejs – chovy
/home/justas ├──[email protected] ├─┬[email protected] – sauletasmiestas