Skip to content

Commit

Permalink
update template2 to use Ring+Moustache
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Sep 1, 2010
1 parent d164384 commit 3e1c9d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/tutorial/template1.clj
@@ -1,6 +1,6 @@
(ns tutorial.template1
(:require [net.cgrand.enlive-html :as html])
(:use [net.cgrand.moustache :only [app delegate]]
(:use [net.cgrand.moustache :only [app]]
[tutorial.utils :only [run-server render-to-response]]))

(html/deftemplate index "tutorial/template1.html"
Expand Down
27 changes: 9 additions & 18 deletions src/tutorial/template2.clj
@@ -1,9 +1,9 @@
(ns tutorial.template2
(:use [net.cgrand.enlive-html
:only [deftemplate defsnippet content clone-for
nth-of-type first-child do-> set-attr sniptest at emit*]])
(:use tutorial.utils)
(:use compojure))
nth-of-type first-child do-> set-attr sniptest at emit*]]
[net.cgrand.moustache :only [app]]
[tutorial.utils :only [run-server render-to-response]]))

;; =============================================================================
;; Dummy Data
Expand Down Expand Up @@ -61,23 +61,14 @@
[:#title] (content title)
[:body] (content (map #(section-model % link-model) sections)))

(defroutes example-routes
(GET "/"
(render (index *dummy-context*)))
(ANY "*"
[404 "Page Not Found"]))
(def routes
(app
[""] (fn [req] (render-to-response (index *dummy-context*)))
[&] {:status 404
:body "Page Not Found"}))

;; ========================================
;; The App
;; ========================================

(defonce *app* (atom nil))

(defn start-app []
(if (not (nil? @*app*))
(stop @*app*))
(reset! *app* (run-server {:port 8080}
"/*" (servlet example-routes))))

(defn stop-app []
(when @*app* (stop @*app*)))
(defonce *server* (run-server routes))

0 comments on commit 3e1c9d6

Please sign in to comment.