This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express.createServer(); | |
app.set('views', __dirname); | |
app.set('view engine', 'html'); | |
app.register('.html', require('ejs')); | |
app.configure(function () { | |
app.use(express.bodyParser()); | |
app.use(express.errorHandler({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(express.compiler({ | |
src: __dirname, | |
enable: ['less'] | |
})); | |
app.use(express.static(__dirname)); | |
app.use(express.errorHandler({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Animal(name) { | |
this.name = name; | |
} | |
Animal.prototype.drink = function (_) { | |
console.log(this.name + " is about to grab a drink at the watering hole..."); | |
// simulate async step: | |
setTimeout(_, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function process(user) { | |
var model = new User(user); | |
model.save(_); | |
} | |
for (var i = 0; i < users.length; i++) { | |
process(users[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj, key, val; | |
obj = { | |
foo: 'bar', | |
hello: 'world' | |
}; | |
for (key in obj) { | |
val = obj[key]; | |
setTimeout(_, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in foo | |
print 'hello' | |
### | |
hello? | |
### | |
print 'world' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Error reporting</h2> | |
<p> | |
Does the error message for this page report the correct line number? | |
</p> | |
<% para = (phrase) -> %> | |
<p><%= phrase %></p> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Multi-Line Blocks</h1> | |
<p> | |
It would be great to support multi-line blocks. | |
Here are some use cases: | |
</p> | |
<% | |
# Documentation via multiple lines of single-line comments. | |
# Like so. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>For-Each</h2> | |
<p> | |
This should print a list of names, no? | |
(It does in EJS.) | |
</p> | |
<% names = ['Alice', 'Bob', 'Carol'] %> | |
<ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Comments ending in colons</h1> | |
<% # This comment ends in a colon: %> | |
<p> | |
That shouldn't be a problem for Eco! But it is. ;) | |
</p> |