Skip to content

Instantly share code, notes, and snippets.

@madstap
Created January 15, 2017 08:00
Show Gist options
  • Save madstap/b61736098b112558145dd5f0f81848c5 to your computer and use it in GitHub Desktop.
Save madstap/b61736098b112558145dd5f0f81848c5 to your computer and use it in GitHub Desktop.
I always forget which fns are parse and unparse in enlive
(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