on master help sign in
Managed to get Yesod.hs compiling.
85f84bcevancz
elm-yesod/Language/Elm/Yesod.hs+5−6
@@ -20,8 +20,7 @@ module Language.Elm.Yesod (toWidget) where
20import Text.Blaze (preEscapedToMarkup)
20import Text.Blaze (preEscapedToMarkup)
21import Text.Hamlet
21import Text.Hamlet
22import Text.Julius
22import Text.Julius
23−import Text.Cassius
23+import Yesod.Widget (toWidgetHead, whamlet, GWidget)
24−import Yesod.Widget
25import Language.Elm
24import Language.Elm
26
25
27-- |toWidget takes some Elm code in String format and produces a widget. Usage example:
26-- |toWidget takes some Elm code in String format and produces a widget. Usage example:
@@ -30,7 +29,7 @@ import Language.Elm
30toWidget :: String -- ^ The Elm source code
29toWidget :: String -- ^ The Elm source code
31 -> GWidget sub master ()
30 -> GWidget sub master ()
32toWidget source =
31toWidget source =
33− let (html, css, js) = toParts source
32+ let (html, css, js) = toParts source in
34− in do toWidgetHead [cassius| css |]
33+ do toWidgetHead [hamlet| #{css} |]
35− toWidgetHead [julius| #{js} |]
34+ toWidgetHead [julius| #{js} |]
36− [whamlet| ^{html} |]
35+ [whamlet| ^{html} |]
elm/src/GenerateHtml.hs+10−9
@@ -11,14 +11,15 @@ import Initialize
11import CompileToJS
11import CompileToJS
12import ExtractNoscript
12import ExtractNoscript
13
13
14+css = H.style ! A.type_ "text/css" $ preEscapedToMarkup
14−css = "* { padding:0; margin:0; \
15+ ("* { padding:0; margin:0; \
15− \hyphens: auto; -moz-hyphens: auto;\
16+ \hyphens: auto; -moz-hyphens: auto;\
16− \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
17+ \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
17− \body { font-family: Arial; }\
18+ \body { font-family: Arial; }\
18− \a:link {text-decoration: none}\
19+ \a:link {text-decoration: none}\
19− \a:visited {text-decoration: none}\
20+ \a:visited {text-decoration: none}\
20− \a:active {text-decoration: none}\
21+ \a:active {text-decoration: none}\
21− \a:hover {text-decoration: underline; color: #ff8f12;}"
22+ \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)
22
23
23makeScript :: String -> H.Html
24makeScript :: String -> H.Html
24makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
25makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
@@ -43,7 +44,7 @@ generateHtml libLoc title source =
43 H.title . H.toHtml $ title
44 H.title . H.toHtml $ title
44 makeScript libLoc
45 makeScript libLoc
45 H.script ! A.type_ "text/javascript" $ preEscapedToMarkup js
46 H.script ! A.type_ "text/javascript" $ preEscapedToMarkup js
46− H.style ! A.type_ "text/css" $ preEscapedToMarkup (css :: String)
47+ css
47 H.body $ body noscript
48 H.body $ body noscript
48
49
49body noscript = do
50body noscript = do
elm/src/Language/Elm.hs+1−1
@@ -31,7 +31,7 @@ toHtml = generateHtml
31-- and JavaScript. The HTML is only the contents of the body, so the three
31-- and JavaScript. The HTML is only the contents of the body, so the three
32-- parts must be combined in a basic HTML skeleton.
32-- parts must be combined in a basic HTML skeleton.
33toParts :: String -- ^ The Elm source code.
33toParts :: String -- ^ The Elm source code.
34− -> (Html, String, String) -- ^ HTML, CSS, and JavaScript in that order.
34+ -> (Html, Html, String) -- ^ HTML, CSS, and JavaScript in that order.
35toParts source = (html, css, js)
35toParts source = (html, css, js)
36 where expr = initialize source
36 where expr = initialize source
37 js = compileToJS expr
37 js = compileToJS expr