net.cgrand.enlive-html
enlive-html is a selector-based transformation and extraction engine.
*options*
dynamic
add-class
(add-class & classes)Adds the specified classes to the selected element.
after
(after & values)Inserts the values after the current selection (node or fragment).
alter-ns-options!
(alter-ns-options! f & args)Sets the default options to use by all templates and snippets in the declaring ns.
annotate
(annotate node)any
any-node
append
(append & values)Appends the values to the content of the selected element.
append!
(append! t)(append! t a)(append! t a b)(append! t a b c)(append! t a b c d)(append! t a b c d e)(append! t a b c d e f)(append! t a b c d e f g)(append! t a b c d e f g & more)as-nodes
(as-nodes node-or-nodes)at
macro
(at node-or-nodes & rules)at*
(at* node-or-nodes rules)attr-contains
Selector predicate, tests if the specified attributes contain the specified values. See CSS *= .
attr-ends
Selector predicate, tests if the specified attributes end with the specified values. See CSS $= .
attr-has
(attr-has attr & values)Selector predicate, tests if the specified whitespace-seperated attribute contains the specified values. See CSS ~=
attr-starts
Selector predicate, tests if the specified attributes start with the specified values. See CSS ^= .
attr-values
(attr-values node attr)Returns the whitespace-separated values of the specified attr as a set or nil.
attr=
Selector predicate, tests if the specified attributes have the specified values.
attr?
(attr? & kws)Selector predicate, tests if the specified attributes are present.
attr|=
Selector predicate, tests if the specified attributes start with the specified values. See CSS |= .
before
(before & values)Inserts the values before the current selection (node or fragment).
but
(but selector-step)Selector predicate, matches elements which are rejected by the specified selector-step. See CSS :not
but-node
(but-node selector-step)Selector predicate, matches nodes which are rejected by the specified selector-step. See CSS :not
cacheable
(cacheable selector)cacheable?
(cacheable? selector)clone-for
macro
(clone-for comprehension & forms)comment-node
content
(content & values)Replaces the content of the element. Values can be nodes or collection of nodes.
defsnippet
macro
(defsnippet name source selector args & forms)Define a named snippet – equivalent to (def name (snippet source selector args …)).
defsnippets
macro
(defsnippets source & specs)deftemplate
macro
(deftemplate name source args & forms)Defines a template as a function that returns a seq of strings.
do->
(do-> & fns)Chains (composes) several transformations. Applies functions from left to right.
emit*
(emit* node-or-nodes)emit-tag
(emit-tag tag t)even
first-child
first-of-type
flatmap
(flatmap f node-or-nodes)flatten-nodes-coll
(flatten-nodes-coll x)fragment-selector?
(fragment-selector? selector)get-resource
multimethod
(get-resource resource loader)Loads a resource, using the specified loader. Returns a seq of nodes.
has
(has selector)Selector predicate, matches elements which contain at least one element that matches the specified selector. See jQuery’s :has
has-class
(has-class & classes)Selector predicate, :.foo.bar is as short-hand for (has-class “foo” “bar”).
html
(html & nodes-specs)Allows to define inline fragments with a hiccup-like syntax.
html-content
(html-content & values)Replaces the content of the element. Values are strings containing html code.
html-resource
(html-resource resource)(html-resource resource options)Loads an HTML resource, returns a seq of nodes.
html-snippet
(html-snippet & values)Concatenate values as a string and then parse it with tagsoup. html-snippet doesn’t insert missing or tags.
id=
(id= id)Selector predicate, :#foo is as short-hand for (id= “foo”).
intersection
(intersection preds)last-child
last-of-type
left
(left selector-step)Selector predicate, matches nodes whose immediate left sibling element is matched by the specified selector-step.
lefts
(lefts selector-step)Selector predicate, matches nodes whose one left sibling element is matched by the specified selector-step.
let-select
macro
(let-select nodes-or-fragments bindings & body)For each node or fragment, performs a subselect and bind it to a local, then evaluates body. bindings is a vector of binding forms and selectors.
lockstep-transform
(lockstep-transform nodes transformations-map)lockstep-transformation
macro
(lockstep-transformation & forms)move
(move src-selector dest-selector)(move src-selector dest-selector combiner)Takes all nodes (under the current element) matched by src-selector, removes them and combines them with the elements matched by dest-selector. By default, destination elements are replaced.
node-selector?
(node-selector? selector)ns-options
(ns-options)(ns-options ns)nth-child
(nth-child b)(nth-child a b)Selector step, tests if the node has an+b-1 siblings on its left. See CSS :nth-child.
nth-last-child
(nth-last-child b)(nth-last-child a b)Selector step, tests if the node has an+b-1 siblings on its right. See CSS :nth-last-child.
nth-last-of-type
(nth-last-of-type b)(nth-last-of-type a b)Selector step, tests if the node has an+b-1 siblings of the same type (tag name) on its right. See CSS :nth-last-of-type.
nth-of-type
(nth-of-type b)(nth-of-type a b)Selector step, tests if the node has an+b-1 siblings of the same type (tag name) on its left. See CSS :nth-of-type.
odd
only-child
only-of-type
pred
(pred f)Turns a predicate function on elements into a predicate-step usable in selectors.
prepend
(prepend & values)Prepends the values to the content of the selected element.
re-pred
(re-pred re)Turns a regex into a predicate-step on text nodes usable in selectors.
register-resource!
multimethod
remove-attr
(remove-attr & attr-names)Dissocs attributes on the selected element.
remove-class
(remove-class & classes)Removes the specified classes from the selected element.
replace-vars
(replace-vars m)(replace-vars re m)(replace-vars re m f)By default, takes a map (or function) of keywords to strings and replaces all occurences of ${foo} by (m :foo) in text nodes and attributes. Does not recurse, you have to pair it with an appropriate selector. re is a regex whose first group will be passed to (comp m f) and f by default is #’keyword.
replace-words
(replace-words words-to-replacements)Takes a map of words to replacement strings and replaces all occurences. Does not recurse, you have to pair it with an appropriate selector.
right
(right selector-step)Selector predicate, matches nodes whose immediate right sibling element is matched by the specified selector-step.
rights
(rights selector-step)Selector predicate, matches nodes whose one left sibling element is matched by the specified selector-step.
root
select
(select node-or-nodes selector)Returns the seq of nodes or fragments matched by the specified selector.
select-fragments*
(select-fragments* nodes selector)select-nodes*
(select-nodes* nodes selector)self-closing-tags
set-attr
(set-attr & kvs)Assocs attributes on the selected element.
set-ns-options!
(set-ns-options! options)Sets the default options to use by all templates and snippets in the declaring ns.
set-ns-parser!
(set-ns-parser! parser)Sets the default parser to use by all templates and snippets in the declaring ns.
snippet
macro
(snippet source selector args & forms)A snippet is a function that returns a seq of nodes.
snippet*
macro
(snippet* nodes & body)sniptest
macro
(sniptest source-string & forms)A handy macro for experimenting at the repl
sniptest*
(sniptest* nodes f)strict-mode
macro
(strict-mode & forms)Adds xhtml-transitional DTD to switch browser in ‘strict’ mode.
strict-mode*
(strict-mode* node)substitute
(substitute & values)Replaces the current selection (node or fragment).
tag=
(tag= tag-name)Selector predicate, :foo is as short-hand for (tag= :foo).
template
macro
(template source args & forms)A template returns a seq of string.
text
(text node)Returns the text value of a node.
text-node
text-pred
(text-pred f)Turns a predicate function on strings (text nodes) into a predicate-step usable in selectors.
texts
(texts nodes)Returns the text value of a nodes collection.
this-node
transform
(transform nodes selector transformation)transform-content
macro
(transform-content & body)transformation
macro
(transformation)(transformation form)(transformation form & forms)union
(union preds)unwrap
void
whitespace
with-options
macro
(with-options m & body)wrap
(wrap tag)(wrap tag attrs)xml-parser
(xml-parser stream)Loads and parse a XML resource and closes the stream.
xml-resource
(xml-resource resource)Loads an XML resource, returns a seq of nodes.
zip-pred
(zip-pred f)Turns a predicate function on elements locs into a predicate-step usable in selectors.
zip-select
(zip-select locs selector)Returns the seq of locs matched by the specified selector.
zip-select-fragments*
(zip-select-fragments* locs state-from state-to)zip-select-nodes*
(zip-select-nodes* locs state)