Skip to content

Instantly share code, notes, and snippets.

@smurphy8
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save smurphy8/e5de315184d139caa32e to your computer and use it in GitHub Desktop.

Select an option

Save smurphy8/e5de315184d139caa32e to your computer and use it in GitHub Desktop.
{-# LANGUAGE CPP, TemplateHaskell, QuasiQuotes #-}
import GHCJS.DOM
import GHCJS.DOM.Document
import GHCJS.DOM.HTMLElement
import GHCJS.DOM.Types
import Text.Hamlet
import Data.Text.Lazy (unpack)
import Text.Blaze.Html.Renderer.Text (renderHtml)
configurationHtmlTemplate example = do
htmlElementSetInnerHTML example . unpack $ renderHtml [shamlet|$newline always
n<div> Test |]
helloDOM doc = do
maybeExample <- documentGetElementById doc "example"
case maybeExample of
Just example -> htmlElementSetInnerText
(castToHTMLElement example)
"Hello World"
Nothing -> putStrLn "Element 'example' not found"
main = do
mdoc <- currentDocument
case mdoc of
Nothing -> putStrLn "Element 'example' not found"
Just doc -> helloDOM doc
Name: stakeout-ghcjs
Version: 0.0.0
Author: Scott <scott.murphy@plowtech.net>
Maintainer: Scott <scott.murphy@plowtech.net>
License: BSD3
License-File: LICENSE
-- Synopsis:
-- Description:
Cabal-Version: >= 1.10
Build-Type: Simple
Library
Default-Language: Haskell2010
HS-Source-Dirs: src
GHC-Options: -Wall
Exposed-Modules: Stakeout.GHCJS
Other-Modules: Stakeout.GHCJS.Internal
Build-Depends: base >= 4 && < 5
, ghcjs-dom -any
, mtl -any
, blaze-html
, hamlet >=1.1.0.2 && <1.2
, template-haskell
, text
Test-Suite spec
Type: exitcode-stdio-1.0
Default-Language: Haskell2010
Hs-Source-Dirs: src
, test
Ghc-Options: -Wall
Main-Is: Spec.hs
Build-Depends: base
, hspec
, lens
Source-Repository head
Type: git
-- Location:
executable stakeout-ghcjs
build-depends: base
, ghcjs-dom -any
, hamlet >=1.1.0.2 && <1.2
, blaze-html
, template-haskell
, text
, mtl
main-is: Main.hs
buildable: True
hs-source-dirs: src
ghc-options: -threaded -rtsopts
Preprocessing executable 'stakeout-ghcjs' for stakeout-ghcjs-0.0.0...
[1 of 1] Compiling Main ( src/Main.hs, dist/build/stakeout-ghcjs/stakeout-ghcjs-tmp/Main.js_o )
Linking template haskell (ThRunner1)
src/Main.hs:12:57:
Exception when trying to run compile-time code:
cannot find module: hamlet-1.1.9.2:Text.Hamlet
searched in:
Code: Language.Haskell.TH.Quote.quoteExp
shamlet
"$newline always\n\
\ <div> Test "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment