Express throwing unexpected token "indent"

784 views
Skip to first unread message

kb

unread,
Jan 14, 2012, 7:20:49 AM1/14/12
to Express
Hi,

I am a noob, and i am trying express for first time.

here's my app.js code

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);

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

Prashanth

unread,
Jan 27, 2012, 1:53:44 AM1/27/12
to expre...@googlegroups.com
On Sat, Jan 14, 2012 at 5:50 PM, kb <keshavab...@gmail.com> wrote:
> app.register('.html', require('jade'));
>

You register .html to render with jade, but you wrote a simple HTML.
Jade is trying to render it that is because you see the error.

--
regards,
Prashanth
twitter: munichlinux
irc: munichlinux, JSLint, munichpython.

Ryan Schmidt

unread,
Jan 29, 2012, 5:39:26 AM1/29/12
to expre...@googlegroups.com

On Jan 14, 2012, at 06:20, kb wrote:

> app.register('.html', require('jade'));

Here, you have told Express that you want it to treat all .html files as if they were Jade files.

Your index.html file is clearly an HTML file, not a Jade file. Either write a Jade file, or don't tell Express to treat .html files as if they were Jade files.

vision media [ Tj Holowaychuk ]

unread,
Jan 29, 2012, 1:18:44 PM1/29/12
to expre...@googlegroups.com
yeah, the reason for .register is for example write a custom .markdown engine wrapping one of the many markdown libs, or mapping .html to the "ejs" engine or perhaps "mustache", those are pretty common




--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.




--
Tj Holowaychuk
Vision Media
President & Creative Lead
Reply all
Reply to author
Forward
0 new messages