Skip to content

Instantly share code, notes, and snippets.

@hby
Created March 21, 2014 04:55
Show Gist options
  • Save hby/9679750 to your computer and use it in GitHub Desktop.
Save hby/9679750 to your computer and use it in GitHub Desktop.
(ns haglure.core
(:require [net.cgrand.enlive-html :as html]))
(def layout
(html/html-resource "test.html"))
(defn scope [n]
(:data-scope (:attrs n)))
(def scopes (html/select layout [(html/attr? :data-scope)]))
(count scopes)
(map scope scopes)
(def posts (html/select layout [(html/attr= :data-scope "post")]))
(def post-comments (html/select posts [(html/attr= :data-scope "comment")]))
(def comments (html/select layout [(html/attr= :data-scope "comment")]))
<html>
<body>
<h1>Posts</h1>
<div class="post" data-scope="post">
<h2 data-prop="title">Title</h2>
<p class="body" data-prop="body">Body</p>
<div class="comment" data-scope="comment">
<p data-prop="body">Comment</p>
</div>
</div>
<div class="comment" data-scope="comment">
<p>Free Comment</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment