MIT licensed and maintained by Neil Mitchell

Module documentation for 3.1.0

js-jquery Hackage version Build Status

This package bundles the minified jQuery code into a Haskell package, so it can be depended upon by Cabal packages. The first three components of the version number match the upstream jQuery version. The package is designed to meet the redistribution requirements of downstream users (e.g. Debian). As an example:

import qualified Language.Javascript.JQuery as JQuery

main = do
    putStrLn $ "jQuery version " ++ show JQuery.version ++ " source:"
    putStrLn =<< readFile =<< JQuery.file

This package installs data files containing the jQuery sources, which must be available at runtime. If you want to produce an executable with no dependency on associated data files, you can use the file-embed library:

{-# LANGUAGE TemplateHaskell #-}

import Data.FileEmbed
import qualified Data.ByteString as BS
import qualified Language.Javascript.JQuery as JQuery
import Language.Haskell.TH.Syntax

main = print jQueryContents

jQueryContents :: BS.ByteString
jQueryContents = $(embedFile =<< runIO JQuery.file)

Or, within the Yesod framework, yesod-static:

{-# LANGUAGE TemplateHaskell, QuasiQuotes, TypeFamilies #-}

import Yesod
import Yesod.EmbeddedStatic
import qualified Language.Javascript.JQuery as JQuery

data MySite = MySite {
    ...
    , getStatic :: EmbeddedStatic
    ...
    }

-- Create a Route `jquery_js` to a statically-serveable version of the local jQuery lib.
mkEmbeddedStatic False "myStatic" . pure . embedFileAt "jquery.js" =<< runIO JQuery.file

mkYesod "PresentationServer" [parseRoutes|
/ HomeR Get
...
/static StaticR EmbeddedStatic getStatic
|]
instance Yesod PresentationServer where
  addStaticContent = embedStaticContent getStatic StaticR Right

getHomeR :: Handler Html
getHomeR = defaultLayout $ do
   addScript $ StaticR jquery_js
   ...

(See also sample-embed.hs.)

Changes

Changelog for js-jquery

3.3.1, released 2018-01-21
New version of jQuery
#1, add a file-embed example
3.2.1, released 2017-03-22
New version of jQuery
3.1.1, released 2016-10-01
New version of jQuery
3.1.0, released 2016-07-09
New version of jQuery
3.0.0, released 2016-06-11
New version of jQuery
1.12.4, released 2016-05-22
New version of jQuery
1.12.3, released 2016-04-06
New version of jQuery
1.12.2, released 2016-03-23
New version of jQuery
1.12.1, released 2016-02-23
New version of jQuery
1.12.0, released 2016-01-10
New version of jQuery
1.11.3, released 2015-05-06
New version of jQuery
1.11.2, released 2014-12-24
New version of jQuery
1.11.1, released 2014-10-06
Initial version
Depends on 1 package:
comments powered byDisqus