Skip to content

Instantly share code, notes, and snippets.

@denzuko
Created May 31, 2012 23:41
Show Gist options
  • Select an option

  • Save denzuko/2847236 to your computer and use it in GitHub Desktop.

Select an option

Save denzuko/2847236 to your computer and use it in GitHub Desktop.
(function() {
describe('Application', function() {
it('should exists', function() {
var app = new Application();
app.should.be.an.instanceof(Application);
});
});
}).call(this);
function Application(template_id){
var source = $(template_id);
this.template = Handlebars.compile(source.html());
}
Application.prototype.render = function(params){
return this.template(params);
};
<script id="test-template" type="text/x-handlebars-template">
<p></p>
</script>
{
"engines": {
"node": "0.6.13",
"npm": "1.1.15"},
"dependencies": {
"express": "2.2.0",
"should": "0.6.5",
"mocha"
"main": app/server.js"
}
var express = require('express'),
app = express.createServer();
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('views');
// => "/absolute/path/to/views"
app.enable('some feature');
// same as app.set('some feature', true);
app.disable('some feature');
// same as app.set('some feature', false);
app.enabled('some feature')
// => false
});
app.get('/', function(req, res){
// res.send('hello world');
});
app.listen(3000);
it('should render handlebars template', function(){
var app = new Application("#test-template");
app.render({name: "kuba"}).should.equal("<p>kuba</p>");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment