From 833c42096eb8e479855bd4ca9ecbfe3bc08a1543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 30 Apr 2025 21:35:27 +0200 Subject: Use blaze-html for markup --- erebos-webapp.cabal | 2 ++ src/Main.hs | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/erebos-webapp.cabal b/erebos-webapp.cabal index 7648849..47c7b58 100644 --- a/erebos-webapp.cabal +++ b/erebos-webapp.cabal @@ -40,6 +40,7 @@ executable erebos-webapp ImportQualifiedPost LambdaCase MultiWayIf + OverloadedStrings RankNTypes RecordWildCards ScopedTypeVariables @@ -53,6 +54,7 @@ executable erebos-webapp -- other-extensions: build-depends: base ^>= { 4.21 }, + blaze-html ^>= { 0.9 }, bytestring ^>= { 0.12 }, erebos ^>= { 0.1.8 }, ghc-experimental ^>= { 9.1201 }, diff --git a/src/Main.hs b/src/Main.hs index 183b038..2a08285 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -23,6 +23,11 @@ import Erebos.Sync import System.IO.Unsafe +import Text.Blaze.Html5 ((!)) +import Text.Blaze.Html5 qualified as H +import Text.Blaze.Html5.Attributes qualified as A +import Text.Blaze.Html.Renderer.String + import JavaScript qualified as JS import WebSocket @@ -43,7 +48,15 @@ foreign export javascript setup :: IO () setup :: IO () setup = do body <- js_document_getElementById (toJSString "body") - js_set_innerHTML body (toJSString "
Name:

") + js_set_innerHTML body $ toJSString $ renderHtml $ do + H.div $ do + "Name: " + H.span ! A.id "name_text" $ return () + H.hr + H.input ! A.id "some_input" ! A.type_ "text" ! A.value "xyz" + H.button ! A.id "some_button" $ "add" + H.div $ do + H.ul ! A.id "some_list" $ return () nameElem <- js_document_getElementById (toJSString "name_text") _ <- watchHead globalHead $ \ls -> do -- cgit v1.2.3