Popularity
4.4
Declining
Activity
0.0
Stable
5
4
1

Monthly Downloads: 23
Programming language: Haskell
License: MIT License
Tags: Web    

hquery alternatives and similar packages

Based on the "Web" category.
Alternatively, view hquery alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of hquery or a related project?

Add another 'Web' Package

README

What is it?

Hquery can be used to manipulate xmlhtml trees (and has a similar selector syntax to jquery, hence the name). This enables easy manipulation and content generation from html templates. If you're familiar with Lift's CssSels, this is basically an implementation of those in haskell.

Build Status

Examples

Suppose you have the template:

<div class="person">
  <div class="name"></div>
  <div class="occupation"></div>
</div>

If you invoke hquery as:

import Text.Hquery
template = ... -- parse your template here
people = [ ("Justin Bieber", "Celebrity")
         , ("Jens Kidman", "Musician")
         ]
bindPerson (n, o) = hq ".name *" n . hq ".occupation *" o
f = hq ".person *" $ map bindPerson people
f template

You'll get:

<div class="person">
  <div class="name">Justin Bieber</div>
  <div class="occupation">Celebrity</div>
</div>
<div class="person">
  <div class="name">Jens Kidman</div>
  <div class="occupation">Musician</div>
</div>

You can also add, remove, and append to element attributes. For example if we have: <div class="foo"></div> , below are some example transformations:

  • hq "div [class+]" "hidden" gives <div class="foo hidden"></div>
  • hq ".foo [id]" "bar" gives <div id="bar" class="foo"></div>
  • hq "* [class!]" "foo" gives <div></div>

Installation

Hquery is availiable on HackageDB, via cabal install hquery.

License

Hquery is MIT licensed.


*Note that all licence references and agreements mentioned in the hquery README section above are relevant to that project's source code only.