packages feed

Shpadoinkle-backend-static 0.1.0.2 → 0.2.0.0

raw patch · 2 files changed

+31/−18 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Shpadoinkle-backend-static.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.32.0.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 9d3d4c783f822f5b3b09c7c4fbe024377cae3b31724f8694584df2e31207f9ac+-- hash: abdea4994cb952fb1705f4fa5521e4317836fd2b39c00be6b2734d5d934a1c46  name:           Shpadoinkle-backend-static-version:        0.1.0.2+version:        0.2.0.0 synopsis:       A backend for rendering Shpadoinkle as Text. description:    Shpadoinkle's static backend, which renders Html as Text. Event listeners are ignored. This is useful when rendering on the server or for static site generation. category:       Web
Shpadoinkle/Backend/Static.hs view
@@ -10,11 +10,11 @@ module Shpadoinkle.Backend.Static ( renderStatic ) where  -import           Control.Compactable-import           Data.Monoid         ((<>))-import           Data.Text+import           Control.Compactable (Compactable (fmapMaybe))+import           Data.Monoid         (mconcat, (<>))+import           Data.Text           (Text, null, unwords) -import           Shpadoinkle         hiding (name, props, text)+import           Shpadoinkle         (Html, Prop (PText), cataH, cataProp)   -- | Render as @Text@@@ -34,9 +34,17 @@   , "img", "input", "link", "meta", "param", "source", "track" ]  +innerHTML :: Text+innerHTML = "innerHTML"++ renderWrapping :: Text -> [(Text, Prop m a)] -> [Text] -> Text-renderWrapping tag props cs = renderOpening tag props <> ">"-  <> mconcat cs <> "</" <> tag <> ">"+renderWrapping tag props cs =+  renderOpening tag props <> ">"+  <> (case innerHTML `lookup` props of+        Just (PText html) -> html+        _                 -> mconcat cs)+  <> "</" <> tag <> ">"   renderSelfClosing :: Text -> [(Text, Prop m a)] -> Text@@ -53,12 +61,17 @@   renderProp :: Text -> Prop m a -> Maybe Text-renderProp name = cataProp renderTextProp renderListener renderFlag--  where renderTextProp t = Just $ lice name <> "=\"" <> t <> "\""-        renderListener _ = Nothing-        renderFlag True  = Just name-        renderFlag False = Nothing-        lice = \case-          "className" -> "class"-          x -> x+renderProp name = cataProp+  (const Nothing)+  renderTextProp+  renderFlag+  (const Nothing)+  (const Nothing)+  where+  renderTextProp t | t == innerHTML = Nothing+                   | otherwise      = Just $ lice name <> "=\"" <> t <> "\""+  renderFlag True  = Just name+  renderFlag False = Nothing+  lice = \case+    "className" -> "class"+    x           -> x