@@ -4,8 +4,10 @@
5module Frontend where
5module Frontend where
7import qualified Data.Text as T
8import qualified Data.Text as T
8import qualified Data.Text.Encoding as T
9import qualified Data.Text.Encoding as T
10+import Language.Javascript.JSaddle (eval, liftJSM)
10import Obelisk.Frontend
12import Obelisk.Frontend
11import Obelisk.Configs
13import Obelisk.Configs
@@ -26,6 +28,13 @@ frontend = Frontend
26 , _frontend_body = do
28 , _frontend_body = do
27 el "h1" $ text "Welcome to Obelisk!"
29 el "h1" $ text "Welcome to Obelisk!"
28 el "p" $ text $ T.pack commonStuff
30 el "p" $ text $ T.pack commonStuff
32+ -- `prerender` and `prerender_` let you choose a widget to run on the server
33+ -- during prerendering and a different widget to run on the client with
34+ -- JavaScript. The following will generate a `blank` widget on the server and
35+ -- print "Hello, World!" on the client.
36+ prerender_ blank $ liftJSM $ void $ eval ("console.log('Hello, World!')" :: T.Text)
29 elAttr "img" ("src" =: static @"obelisk.jpg") blank
38 elAttr "img" ("src" =: static @"obelisk.jpg") blank
30 el "div" $ do
39 el "div" $ do
31 exampleConfig <- getConfig "common/example"
40 exampleConfig <- getConfig "common/example"