-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marko Mikulicic
committed
Mar 29, 2010
0 parents
commit 84187d5
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pom.xml | ||
*jar | ||
lib | ||
classes |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# haml-macro | ||
|
||
Example of Off-side rule parser using monadic parsers | ||
|
||
## Usage | ||
|
||
FIXME: write | ||
|
||
## Installation | ||
|
||
FIXME: write | ||
|
||
## License | ||
|
||
FIXME: write |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(defproject haml-macro "1.0.0-SNAPSHOT" | ||
:description "macro which takes haml and generate compojure compatible html rendering" | ||
:dependencies [[org.clojure/clojure "1.1.0"] | ||
[org.clojure/clojure-contrib "1.1.0"] | ||
[clarsec "0.0.1-SNAPSHOT"] | ||
]) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
(ns haml-macro.core | ||
(:use [eu.dnetlib.clojure clarsec monad])) | ||
|
||
(def newlinep (one-of "\n")) | ||
|
||
(def anyChar (not-char \newline)) | ||
|
||
(defn prefixed [ch p] | ||
(>> (is-char ch) p)) | ||
|
||
(def tagName (prefixed \% baseIdentifier)) | ||
(def idName (prefixed \# baseIdentifier)) | ||
(def className (prefixed \. baseIdentifier)) | ||
|
||
(def tag (let-bind [t (optional tagName) | ||
i (optional idName) | ||
c (many className) | ||
b (optional (>> space text))] | ||
(let [cc (if (empty? c) nil c) | ||
tn (if (nil? t) "div" t)] | ||
(if (every? nil? [t i cc]) | ||
fail | ||
(result [:tag tn i c b]))))) | ||
|
||
(def text (>>== (many anyChar) #(vector :text (apply str %)))) | ||
|
||
(def statement (either tag text)) | ||
|
||
(def statements (followedBy (sepBy1 statement newlinep) (optional newlinep))) | ||
|
||
(def body statements) | ||
|
||
(def source | ||
(followedBy body (lexeme eof))) | ||
|
||
(defn haml [strn] | ||
(:value (parse source strn))) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns haml-macro.core-test | ||
(:use [haml-macro.core] :reload-all) | ||
(:use [clojure.test])) | ||
|
||
(deftest replace-me ;; FIXME: write | ||
(is false)) |