快速抛出意外的令牌“缩进". [英] Express throwing unexpected token "indent"

查看:54
本文介绍了快速抛出意外的令牌“缩进".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提供使用jquery和其他库的静态html文件 而且我想知道如何使用快递.

I'm trying to deliver a static html file which uses jquery and other libraries and i want to know how to do his with express.

这是我的app.js代码(快速服务器文件)

Here's my app.js code ( express server file )

var express = require('express') 
 , routes = require('./routes') 
var app = module.exports = express.createServer(); 
app.configure(function(){ 
 app.set('views', __dirname + '/views'); 
 app.use(express.static(__dirname + '/public')); 
}); 

app.configure('development', function(){ 
 app.use(express.errorHandler({ dumpExceptions: true, showStack: 
true })); 
}); 

app.configure('production', function(){ 
 app.use(express.errorHandler()); 
}); 

app.register('.html', require('jade')); 
app.get('/', function(req, res) { 
   res.render('index.html'); 
}); 

app.listen(3000); 

我的index.html是

and my index.html is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// 
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html> 
<head> 
<link rel='stylesheet' type='text/css' href='theme.css' /> 
<link rel='stylesheet' type='text/css' href='fullcalendar.css' /> 
<link rel='stylesheet' type='text/css' href='fullcalendar.print.css' 
media='print' /> 
<script type='text/javascript' src='jquery-ui-1.8.11.custom.min.js'></ 
script> 
<script type='text/javascript' src='jquery-1.5.2.min.js'></script> 
<script type='text/javascript' src='fullcalendar.min.js'></script> 
<script type='text/javascript'> 
       $(document).ready(function() { 
               $('#calendar').fullCalendar({ 
                       theme: true, 
                       header: { 
                               left: 'prev,next today', 
                               center: 'title', 
                               right: 'month' 
                       }, 
                       editable: true, 
                       events: { url : 'http://localhost:5555/'}, 
                       firstDay : 1, 
                       weekends : true 
               }); 
       }); 
</script> 
<style type='text/css'> 
       body { 
               margin-top: 40px; 
               text-align: center; 
               font-size: 13px; 
               font-family: "Lucida 
Grande",Helvetica,Arial,Verdana,sans-serif; 
               } 
       #calendar { 
               width: 900px; 
               margin: 0 auto; 
               } 
</style> 
</head> 
<body> 
<div id='calendar'></div> 
</body> 
</html> 

并且当我运行服务器并将浏览器指向该服务器时,出现提示错误

and when i run my server and point my browser to it, i get foll error

Error: D:\Workspace\nodejs\test\my-server/views/index.html:12 
   10| <script type='text/javascript'> 
   11| 
 > 12|         $(document).ready(function() { 
   13| 
   14|                 $('#calendar').fullCalendar({ 
   15|                         theme: true, 
unexpected token "indent" 
   at Object.parseExpr (D:\Workspace\nodejs\test\my-server 
\node_modules\jade\lib\parser.js:228:15) 
   at Object.parse (D:\Workspace\nodejs\test\my-server\node_modules 
\jade\lib\parser.js:129:25) 
   at parse (D:\Workspace\nodejs\test\my-server\node_modules\jade\lib 
\jade.js:101:62) 
   at Object.compile (D:\Workspace\nodejs\test\my-server\node_modules 
\jade\lib\jade.js:148:9) 

我最初进行了谷歌搜索,但是算不上什么.. 可以通知自己,这是怎么回事. 谢谢

I did initial googling, but coudn't figure much.. can somone let know wht's happening. Thanks

推荐答案

仅适用于正在经历此挑战的人. 您最有可能在这里按照示例进行操作.

just for anyone who is going though this . You are most probably following the example over here .

https://github.com/visionmedia/express/blob/master/examples/ejs/index.js

和事件,如果您不愿意并且仍然对提供html文件感兴趣.那么您需要做的就是使用ejs.

and event if your not and still interested in serving html files . then all you need to do is use ejs .

如果您的项目未使用玉器模板,则只需从中编辑package.json文件:

if your project is not using jade templates then just edit you package.json file from this :

"jade": "*"

对此

"ejs": "*"

然后按照下面的app.js配置进行操作就好了:

and then your all good to go with the following app.js configuration :

app.engine('.html', require('ejs').__express);

app.set('view engine', 'html');

确保事物的顺序很重要.

sure thing order is important .

这篇关于快速抛出意外的令牌“缩进".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆