Created
January 15, 2017 08:00
-
-
Save madstap/b61736098b112558145dd5f0f81848c5 to your computer and use it in GitHub Desktop.
I always forget which fns are parse and unparse in enlive
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
(ns foo.core | |
(:require | |
[net.cgrand.enlive-html :as e])) | |
(def x "<p>asd</p><a href=\"google.com\">google</a>") | |
;; Parse | |
(def y (e/html-snippet x)) | |
y ;=> ({:tag :p, :attrs nil, :content ("asd")} {:tag :a, :attrs {:href "google.com"}, :content ("google")}) | |
;; Unparse | |
(= x (->> (e/emit* y) | |
(apply str))) ;=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment