Code Monkey home page Code Monkey logo

js-jquery's Introduction

js-jquery Hackage version Stackage 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.)

js-jquery's People

Contributors

felixonmars avatar leftaroundabout avatar ndmitchell avatar tom-bop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

js-jquery's Issues

Decrease lower bound on `Cabal`?

Would it be possible to decrease the required Cabal version to 1.8 instead of 1.18? I'm not sure if this library requires any specific feature that's not available in 1.8

The reason I'm asking is that 1.8 is the Cabal version that usually ships with ghc 7.6.3. I understand that users can upgrade Cabal so it's not a high priority thing to fix

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.