Skip to content

Instantly share code, notes, and snippets.

@claj
Last active January 1, 2016 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claj/8127150 to your computer and use it in GitHub Desktop.
Save claj/8127150 to your computer and use it in GitHub Desktop.
Enlive with special unicode characters - it's possible
;;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