Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

mustache!

  • Loading branch information...
commit 52526172e387fabab13b39fc0dc2767696bc3a89 1 parent f959ecf
Chris Wanstrath authored October 09, 2009
0  README → README.md
Source Rendered
File renamed without changes
17  app.rb
... ...
@@ -0,0 +1,17 @@
  1
+require 'sinatra/base'
  2
+require 'mustache/sinatra'
  3
+
  4
+class App < Sinatra::Base
  5
+  register Mustache::Sinatra
  6
+
  7
+  set :views,     'templates/'
  8
+  set :mustaches, 'views/'
  9
+
  10
+  get '/' do
  11
+    mustache :index
  12
+  end
  13
+
  14
+  get '/other' do
  15
+    mustache :other
  16
+  end
  17
+end
5  config.ru
... ...
@@ -0,0 +1,5 @@
  1
+require 'app'
  2
+
  3
+use Rack::ShowExceptions
  4
+
  5
+run App.new
5  templates/index.mustache
... ...
@@ -0,0 +1,5 @@
  1
+<h1>{{title}}</h1>
  2
+
  3
+<p>{{content}}</p>
  4
+
  5
+<a href="/other">The Other Page</a>
18  templates/layout.mustache
... ...
@@ -0,0 +1,18 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+  <head>
  4
+    <title>
  5
+      Trust the Stache
  6
+    </title>
  7
+    <link href='http://ajax.googleapis.com/ajax/libs/yui/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css' media='screen' rel='stylesheet'/>
  8
+    <link href='http://ajax.googleapis.com/ajax/libs/yui/2.7.0/build/base/base-min.css' media='screen' rel='stylesheet'/>
  9
+    <link href='/styles.css' media='screen' rel='stylesheet'/>
  10
+    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
  11
+    <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js'></script>
  12
+  </head>
  13
+  <body>
  14
+    <div id="main">
  15
+      {{{yield}}}
  16
+    </div>
  17
+  </body>
  18
+</html>
7  templates/other.mustache
... ...
@@ -0,0 +1,7 @@
  1
+<style>
  2
+pre { text-align: left }
  3
+</style>
  4
+
  5
+<pre>{{ascii_art}}</pre>
  6
+
  7
+<a href="/">Home</a>
13  views/index.rb
... ...
@@ -0,0 +1,13 @@
  1
+class App
  2
+  module Views
  3
+    class Index < Mustache
  4
+      def title
  5
+        "The Index"
  6
+      end
  7
+
  8
+      def content
  9
+        "Welcome! Mustache lives."
  10
+      end
  11
+    end
  12
+  end
  13
+end
50  views/other.rb
... ...
@@ -0,0 +1,50 @@
  1
+class App
  2
+  module Views
  3
+    class Other < Mustache
  4
+      def ascii_art
  5
+        <<-end_art
  6
+....................
  7
+....................
  8
+.............:~I7777777777+.                     .,I7777777777I:.
  9
+.............778OOOOOOOOO88=                    ..IOOOOOOOOOOOO++
  10
+.............77OOOOOOOOOOOOO,,                  ~=8OOOOOOOOOOO8++
  11
+.............778OOOOOOOOOOOOII..               .ZZOOOOOOOOOOOOO++
  12
+.............77OOOOOOOOOOOOOO8$.             .:O8OOOOOOOOOOOOO8++
  13
+            .77OOOOOOOOOOOOO88O+.            ..788OOOOOOOOOOOOO8++.......
  14
+            .778OOOOOOOOOOOOOO8O,           .=OOOOOOOOOOOOOOOO8++.......
  15
+            .77OOOOOOOOOOOOOOOOO7.         .,ZOOOOOOOOOOOOOOOOO++.......
  16
+            .77OOOOOOOOOOOOOOOOOOZ$..      :OZOOOOOOOOOOOOOOOOOO++.......
  17
+            .778OOOOOOOOOOOOOOOOOOO?.... .$OOOOOOOOOOOOOOOOOOOO++.......
  18
+            .77OOOOOOOOOOOOOOOOOOOOO: ...=O8OOOOOOOOOOOOOOOOOO8++.......
  19
+            .77OOOOOOOO8OOOOOOOOOOOO$...,OOOOOOOOOOO8OOOOOOOOO8++.......
  20
+            .778OOOOOOO8OO:OOOOOOOOOOO==OOOOOOOOOOZ:OOOOOOOOOO8++.......
  21
+            .778OOOOOOOOO8.IOOOOOOOO8O8OOOOOOOOOOO=:O8OOOOOOOO8++.......
  22
+            .778OOOOOOOOO8.:OOOOOOOOOOOOOOOOOOOO$$.:OOOOOOOOOOO++.......
  23
+            .77OOOOOOOOOO8..??OOOOOOOOOOOOOOOOOO~:.:OOOOOOOOOO8++.......
  24
+            .77OOOOOOOOOO8....+OOOOOOOOOOOOOOOO:...:OOOOOOOOOO8++.......
  25
+            .77OOOOOOOOOO8.....OOOOOOOOOOOOOOOI....:O8OOOOOOOOO++.......
  26
+            .778OOOOOOOOO8.....=OOOOOOOOOOOOOO:.   :OOOOOOOOOO8++
  27
+            .77OOOOOOOOOO8......$88OOOOOOOOO8I     :O8OOOOOOOO8++
  28
+            .778OOOOOOOOO8.......$$OOOOOOOO??.     :OOOOOOOOOOO++
  29
+            .77OOOOOOOOOO8...... ~:OOOOOOOO,,      :OOOOOOOOOOO++
  30
+            .77O8OOOOOOOO8.........7O8OOOO+.       :OOOOOOOOOO8++
  31
+            .~~7777777777+.........,77777I. ....   .?7777777777:,
  32
+                . . ......=$OOOOOOO$=....~?7$$$$77+, ..     .
  33
+                    ....,7OOOOOOOOO8O=..=OOO88O88OOZ:...
  34
+                    ..:ZZOOOOOOOOOOOOZ,,OOOOOOOOOOO8O=+.
  35
+                  ...=8OOOOOOOOOOOOOOO++OOOOOOOOOOOOOOOI,..
  36
+                .,$$8OOOOOOOOOOOOOOOOO$$OOOOOOOOOOOOOOOO8O==
  37
+              ..~O8OOOOOOOOOOOOOOOOO8O$$OOOOOOOOOOOOOOOOOOOO?..
  38
+            ...?OOOOOOOOOOOOOOOOOOOOOO++OOOOOOOOOOOOOOOOOOOOO$,..
  39
+         ...,$$OOOOOOOOOOOOOOOOOOOO887:,OOOOOOOOOOOOOOOOOOOOOOO~=..
  40
+  :77III7$O8O8OOOOOOOOOOOOOOOOOOOO87,....+8OOOOOOOOOOOOOOOOOOOOOO8OI======+.
  41
+  .$$8OOOOOOOOOOOOOOOOOOOOOOOO8OO++..... .~ZZOOOOOOOOOOOOOOOOOOOOOOOOOOOO$7.
  42
+   ,,$8OOOOOOOOOOOOOOOOOO8O888O$: ......   ,,I8888OOOOOOOOOOOOOOOOOO88O8$,,
  43
+     .=$OOOOOOOOO8OOOO8O88OZ7I~.........    ..~IOZOO8OOOOOOOOO8O88O8O8O?.
  44
+            ...,,,,,....................             ..,~======~~,.
  45
+                    ....................
  46
+end_art
  47
+      end
  48
+    end
  49
+  end
  50
+end

0 notes on commit 5252617

Please sign in to comment.
Something went wrong with that request. Please try again.