2015-06-29 30 views
0

您好我想使用服务索引呈现模板从自定义函数,但如果我将函数传递给“模板:”我得到错误“字符串要求”。我可以做什么?如何使用服务索引与功能,而不是模板

var app = require("express"); 
var serveIndex = require("serve-index"); 

app.use('/ftp', serveIndex('public/ftp', { 
'icons': true, 
'template': function(){}// and this is my problem, what i shuld write this? 


})) 

app().listen(3000) 
+1

请编辑您的问题以包含您尝试使用的功能。感谢您提高问题的参考价值并使其更具责任感! –

+0

我想从自定义函数渲染模板,但我不知道如何? –

回答

0

我不能完全确定你打算如何使用而无需首先将其实例化表达,但是,一旦我添加了代码实例化,并实施了模板回调正确的函数签名,似乎上班。

var express = require("express"); 
var serveIndex = require("serve-index"); 

var app = express(); 

app.use('/ftp', serveIndex('/tmp/ftp', { 
    'icons': true, 
    'template': function(locals, cb){ 
    cb(null, "<html><body><h1>It could WORK!!!</h1></body></html>"); 
}})); 

app.listen(3000) 
相关问题