@@ -4,8 +4,10 @@
44
55module Frontend where
66
7+import Control.Monad
78import qualified Data.Text as T
89import qualified Data.Text.Encoding as T
10+import Language.Javascript.JSaddle (eval, liftJSM)
911
1012import Obelisk.Frontend
1113import Obelisk.Configs
@@ -26,6 +28,13 @@ frontend = Frontend
2628 , _frontend_body = do
2729 el "h1" $ text "Welcome to Obelisk!"
2830 el "p" $ text $ T.pack commonStuff
31+
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)
37+
2938 elAttr "img" ("src" =: static @"obelisk.jpg") blank
3039 el "div" $ do
3140 exampleConfig <- getConfig "common/example"