Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

doesn't require .haml extension as parameter

fix layout's yield with multiple nodes
  • Loading branch information...
commit 5fe376431f2dbc250f25089162e5de7b6419f2ab 1 parent 8fa212c
@mmikulicic authored
Showing with 7 additions and 7 deletions.
  1. +1 −1  README.md
  2. +1 −1  src/haml_macro.clj
  3. +5 −5 src/haml_macro/core.clj
View
2  README.md
@@ -5,7 +5,7 @@ USAGE:
(:use haml-macro))
(defroutes greeter
- (GET "/hello/:first/:last" (haml "example.haml")))
+ (GET "/hello/:first/:last" (haml "example")))
see views/example.haml
View
2  src/haml_macro.clj
@@ -2,6 +2,6 @@
(:use haml-macro.core))
(defmacro haml [file]
- (apply list compojure/html (haml-file file)))
+ (apply list compojure/html (haml-macro.core/haml-file-with-layout file)))
(defn set-templates-dir [dir] (reset! *templates-dir* dir))
View
10 src/haml_macro/core.clj
@@ -85,25 +85,25 @@
(def *templates-dir* (atom "views"))
(defn haml-file-name [file]
- (str @*templates-dir* "/" file))
+ (str @*templates-dir* "/" file ".haml"))
(defn haml-file [file]
- (haml-str (slurp (str @*templates-dir* "/" file))))
+ (haml-str (slurp (str @*templates-dir* "/" file ".haml"))))
(defn layout-path []
- (str "layouts/" "application.haml"))
+ (str "layouts/" "application"))
(defn build-layout [l]
(list 'fn ['yield] (apply list 'list l)))
(defn load-layout []
(let [lp (layout-path)]
- (build-layout (if (.exists (java.io.File. (str @*templates-dir* "/" lp)))
+ (build-layout (if (.exists (java.io.File. (str @*templates-dir* "/" lp ".haml")))
(haml-file lp)
'yield))))
(defn haml-file-with-layout [file]
- ((eval (load-layout)) (haml-file file)))
+ ((eval (load-layout)) (apply list 'list (haml-file file))))
(defn eval-haml-file [file]
(eval (apply list compojure/html (haml-file file))))
Please sign in to comment.
Something went wrong with that request. Please try again.