Skip to content

Instantly share code, notes, and snippets.

View cfurrow's full-sized avatar
🐢
Can you fix my bugs faster than I can write them? I doubt it.

Carl Furrow cfurrow

🐢
Can you fix my bugs faster than I can write them? I doubt it.
View GitHub Profile
// 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>
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"});
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');
// ...
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++){
// ...
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){
.item
!= haml_func({name:name,description:description})
gem install rack
gem install tilt
gem install sinatra
gem install haml
gem install RedCloth
gem install Maruku
export GEM_HOME="$HOME/.gems"
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
$ git clone git://github.com/gma/nesta.git
# ... 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