Last active
January 1, 2016 09:49
-
-
Save claj/8127150 to your computer and use it in GitHub Desktop.
Enlive with special unicode characters - it's possible
This file contains hidden or 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
;;create a lein new something | |
;;add [enlive "1.1.5"] to project.clj | |
;;lein repl: | |
(use 'net.cgrand.enlive-html) | |
;;define a simple template "inline" | |
(deftemplate abc | |
(java.io.StringReader. | |
"<html> | |
<head> | |
<meta charset=\"utf-8\"/> | |
</head> | |
<body> | |
<div>hello unicode!</div> | |
</body> | |
</html>") | |
[s] [:div] (content s)) ;;select div-tag, set its content to s | |
;;spit out an html file next to project.clj | |
(spit "charsettest.html" (apply str (abc "\u00bb hello \u2014 unicode!"))) | |
;;open the file in firefox, "works on my machine" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment