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
// app.js | |
// .. other requires | |
require('./public/javascript/date.format'); | |
// index.haml | |
%h1= client.name | |
.modified= client.modified_on.format("m/dd/yy h:MM TT") | |
//output | |
<h1>Client #1</h1> |
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 haml_text = ".item"; | |
haml_text += " .name= name"; | |
haml_text += " .desc= description"; | |
var item_template = Haml(haml_text); | |
var html = item_template({name:"some name",description:"here's a description"}); |
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 Haml = require('haml'); | |
exports.templates = {}; | |
var fs = require('fs'); | |
function createTemplate(filename){ | |
var haml = fs.readFileSync(filename,'utf8'); | |
return Haml(haml); | |
} | |
exports.templates['item'] = createTemplate('./views/_item.haml'); |
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 templates = require('./haml_loader'); | |
// ... | |
// List all items, return html | |
app.get('/items/all',function(req,res){ | |
Item.find().all(function(items){ | |
var item_haml = templates['item']; | |
var output = ""; | |
for(var i=0; i<items.length; 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 templates = require('./haml_loader'); | |
// ... | |
app.get('/item/edit/:id',function(req,res){ | |
var item_edit = templates['item_edit']; | |
Item.findById(req.params.id,function(data){ |
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
.item | |
!= haml_func({name:name,description:description}) |
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
gem install rack | |
gem install tilt | |
gem install sinatra | |
gem install haml | |
gem install RedCloth | |
gem install Maruku |
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
export GEM_HOME="$HOME/.gems" | |
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" |
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
$ git clone git://github.com/gma/nesta.git |
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
# ... snipped | |
Nesta::Plugins.load_local_plugins #=> Should load gist_helper.rb, below | |
module Nesta | |
class App < Sinatra::Base | |
register Sinatra::Cache | |
set :root, File.dirname(__FILE__) | |
set :cache_enabled, Config.cache |
OlderNewer