This file contains hidden or 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
$:.unshift 'lib' | |
$:.unshift '../mustache/examples' | |
require 'temple' | |
require 'pp' | |
require 'benchmark' | |
require 'simple' | |
# A pretty basic Mustache engine | |
class MustacheEngine < Temple::Engine |
This file contains hidden or 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
# re: http://ozmm.org/posts/return_early.html | |
def logger | |
@logger ||= Logger.new(STDOUT).tap { |l| l.level = Logger::WARN } | |
end |
This file contains hidden or 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
tic-tac-toe $ cd new_game | |
new_game $ ls -l | |
total 72 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 1 -> /Users/magnus/programming/random/tic-tac-toe/db/2100000000 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 2 -> /Users/magnus/programming/random/tic-tac-toe/db/2010000000 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 3 -> /Users/magnus/programming/random/tic-tac-toe/db/2001000000 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 4 -> /Users/magnus/programming/random/tic-tac-toe/db/2000100000 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 5 -> /Users/magnus/programming/random/tic-tac-toe/db/2000010000 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 6 -> /Users/magnus/programming/random/tic-tac-toe/db/2000001000 | |
lrwxr-xr-x 1 magnus magnus 58 Dec 25 23:46 7 -> /Users/magnus/programming/random/tic-tac-toe/db/2000000100 |
This file contains hidden or 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
Rehearsal -------------------------------------------------- | |
Liquid 0.480000 0.000000 0.480000 ( 0.485351) | |
Solid 0.100000 0.000000 0.100000 ( 0.106081) | |
Solid (cached) 0.090000 0.000000 0.090000 ( 0.086169) | |
----------------------------------------- total: 0.670000sec | |
user system total real | |
Liquid 0.440000 0.010000 0.450000 ( 0.440790) | |
Solid 0.110000 0.000000 0.110000 ( 0.106895) | |
Solid (cached) 0.060000 0.000000 0.060000 ( 0.063174) |
This file contains hidden or 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
class MustacheGenerator | |
def initialize(options = {}) | |
@options = options | |
end | |
def compile(exp) | |
"\"#{compile!(exp)}\"" | |
end | |
def compile!(exp) |
This file contains hidden or 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
Current Ruby parsers exposed to runtime. | |
| ruby_parser | Ripper | JRuby's parser | Melbourne | | |
MRI 1.8 | X | | | X | | |
MRI 1.9 | X | X | | X | | |
JRuby | X | | X | | | |
MacRuby | X | X | | X | | |
Rubinius | X | | | X | | |
--------------------------------------------------------------- | |
1.8 code | X | | X | X | |
This file contains hidden or 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
## Ruby Quiz #666 | |
module Special | |
CONSTANT = 1 | |
end | |
module Base | |
end | |
class Specific |
This file contains hidden or 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
T = {} | |
L = :layout | |
# Finds a template, returning either: | |
# | |
# false # => Could not find template | |
# true # => Found template in Views | |
# instance of Tilt # => Found template in a file | |
def lookup(n) | |
T.fetch(n.to_sym) do |k| |
This file contains hidden or 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
$ JIT=true CACHED=true ruby -rubygems benchmarks/speed.rb | |
user system total real | |
ERB w/ caching 0.180000 0.000000 0.180000 ( 0.183660) | |
HAML w/ caching 0.790000 0.010000 0.800000 ( 0.799260) | |
{{ w/ caching 0.370000 0.010000 0.380000 ( 0.381047) | |
$ CACHED=true ruby -rubygems benchmarks/speed.rb | |
user system total real | |
ERB w/ caching 0.180000 0.000000 0.180000 ( 0.182621) | |
HAML w/ caching 0.780000 0.010000 0.790000 ( 0.793207) | |
{{ w/ caching 0.790000 0.000000 0.790000 ( 0.790434) |
This file contains hidden or 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
From 443bb9adce83c139ef1896d193b6526d083044ea Mon Sep 17 00:00:00 2001 | |
From: Magnus Holm <[email protected]> | |
Date: Mon, 24 May 2010 23:19:18 +0200 | |
Subject: [PATCH] Fixes #49 | |
--- | |
lib/mustache/generator.rb | 2 +- | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
diff --git a/lib/mustache/generator.rb b/lib/mustache/generator.rb |