packages feed

reflex-dom-th 0.3.0.0 → 0.3.0.1

raw patch · 3 files changed

+21/−10 lines, 3 filesdep +th-lift-instancesPVP ok

version bump matches the API change (PVP)

Dependencies added: th-lift-instances

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for reflex-dom-th +## 0.3.01+* pre sorting and packing of attribute maps to text+** this solves a problem with empty attributes like in <tag attr="">++ ## 0.3.00 -- 2022-03-02  * support for dynamic attributes
reflex-dom-th.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               reflex-dom-th-version:            0.3.0.0+version:            0.3.0.1  -- A short (one-line) description of the package. synopsis: reflex-dom-th transpiles HTML templates to haskell code for reflex-dom@@ -41,6 +41,7 @@             , megaparsec             , reflex-dom-core             , template-haskell+            , th-lift-instances             , text   ghc-options: -Wall -fwarn-tabs   hs-source-dirs:   src
src/Reflex/Dom/TH.hs view
@@ -14,8 +14,12 @@ import Reflex.Dom.TH.Parser import Reflex.Dom.Widget.Basic  import qualified Data.Map as M-import Data.List (insert)+import Data.List (insert, sortBy) import Data.Array+import Data.Text (Text)+import qualified Data.Text as T+import Data.Function (on)+import Instances.TH.Lift  type Ref = Int @@ -33,7 +37,7 @@                          , cChildRefs :: [Ref]                          , cOutRefs :: [Ref]                          , cMyRef :: Maybe Ref-                         , cAttrs :: [(String, String)]+                         , cAttrs :: [(Text, Text)]                          , cDynAttrs :: Maybe String                          , cChilds :: Chain }                | CText String@@ -54,11 +58,12 @@ compile ((TElement {..}):etail) inRefs =       CBind elem' (CRTuple tRef childRefs) (compile etail expRefs)   where-    elem' = CElement tTag inRefs childRefs outRefs tRef tAttrs tDynAttrs childChain+    elem' = CElement tTag inRefs childRefs outRefs tRef attrs tDynAttrs childChain     childChain = compile tChilds []     childRefs = chainOut childChain     outRefs = maybe id insert tRef childRefs      expRefs = merge inRefs outRefs+    attrs    = sortBy (compare `on` fst) [ (T.pack k, T.pack v) | (k, v) <- tAttrs ]   compile (TWidget w r:etail)  inRefs =   CBind (CWidget w r) (maybe CREmpty CRSimple r) (compile etail expRefs)@@ -83,19 +88,19 @@                                                 , tupP $ map (varP . var) crefs]]                                       -elWithAttr :: String -> [(String, String)] -> Maybe String -> ExpQ+elWithAttr :: String -> [(Text, Text)] -> Maybe String -> ExpQ elWithAttr tag [] Nothing = [| el tag |] elWithAttr tag [] (Just dynAttr) = [| elDynAttr tag $(unboundVarE $ mkName dynAttr) |] elWithAttr tag [("class", cl)] Nothing = [| elClass tag cl |]-elWithAttr tag attr Nothing = [| elAttr tag (M.fromList attr) |]-elWithAttr tag attr (Just dynAttr) = [| elDynAttr tag (flip M.union (M.fromList attr) <$>  $(unboundVarE $ mkName dynAttr)) |]+elWithAttr tag attr Nothing = [| elAttr tag (M.fromAscList attr) |]+elWithAttr tag attr (Just dynAttr) = [| elDynAttr tag (flip M.union (M.fromAscList attr) <$>  $(unboundVarE $ mkName dynAttr)) |] -el'WithAttr :: String -> [(String, String)] -> Maybe String  -> ExpQ+el'WithAttr :: String -> [(Text, Text)] -> Maybe String  -> ExpQ el'WithAttr tag [] Nothing = [| el' tag |] el'WithAttr tag [] (Just dynAttr) = [| elDynAttr' tag $(unboundVarE $ mkName dynAttr) |] el'WithAttr tag [("class", cl)] Nothing = [| elClass' tag cl |]-el'WithAttr tag attr Nothing = [| elAttr' tag (M.fromList attr) |]-el'WithAttr tag attr (Just dynAttr) = [| elDynAttr' tag (flip M.union (M.fromList attr) <$>  $(unboundVarE $ mkName dynAttr)) |]+el'WithAttr tag attr Nothing = [| elAttr' tag (M.fromAscList attr) |]+el'WithAttr tag attr (Just dynAttr) = [| elDynAttr' tag (flip M.union (M.fromAscList attr) <$>  $(unboundVarE $ mkName dynAttr)) |]   cchain :: (Ref -> Name) -> Chain ->  ExpQ