Skip to content

mkmik/haml-macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

INTRODUCTION:

This is a Haml implementation for clojure. Currently the main target is the compojure framework.

Wherever haml expects ruby expressions, here you can use clojure expressions. In some cases ruby compatibility is maintained as much as possible, especially to enable cut&paste of existing Haml templates from/to the ruby world.

USAGE:

Leiningen:

[haml-macro "1.0.1-SNAPSHOT"]

example:

(ns example)
    (:use compojure)
    (:use haml-macro))

(defroutes main-routes
  (GET "/hello/:first/:last" []
     (haml "index"))

(def app
  (wrap-reload #'main-routes '(authfile.gui)))

(run-jetty app {:port 4000}))


(defroutes greeter
  (GET "/hello/:first/:last" (haml "example")))

see views/example.haml

you can change the directory where the templates are searched with:

(set-template-dir "somepath")

haml is compiled to clojure code, you need to reload your module from REPL to see your changes in HAML.

you can put layouts in the views/layouts directory, by default it will be loaded a views/layouts/application.haml. It should behave like the normal ruby haml layouts, using "yield":

%html
    %body
        = yield

DISCLAIMER:

the whole thing it's slightly hackish, but I use it for real work so I will normally keep fixing things until they work :-)

About

clojure macro which takes a haml file and generate compojure compatible html rendering code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published