packages feed

reflex-dom-helpers 0.1.0.0 → 0.2.0.0

raw patch · 10 files changed

+82/−41 lines, 10 filesdep +textdep ~reflexdep ~reflex-domnew-uploader

Dependencies added: text

Dependency ranges changed: reflex, reflex-dom

Files

reflex-dom-helpers.cabal view
@@ -1,7 +1,8 @@ name:                reflex-dom-helpers-version:             0.1.0.0-synopsis:            Element tag helpers for working with reflex-dom-description:         Please see README.md+version:             0.2.0.0+synopsis:            Html tag helpers for reflex-dom+description:         Allows one to write html tags as top level functions in reflex-dom,+                                     such as img instead of el "img". homepage:            https://github.com/layer-3-communications/reflex-dom-helpers license:             BSD3 license-file:        LICENSE@@ -18,6 +19,7 @@       Reflex.Tags     , Reflex.Tags.Simple     , Reflex.Tags.SimplePrime+    , Reflex.Tags.SimpleClass     , Reflex.Tags.Attr     , Reflex.Tags.AttrPrime     , Reflex.Tags.DynAttr@@ -25,9 +27,10 @@     , Reflex.Tags.TH   build-depends:       base >= 4.7 && < 5-    , reflex-    , reflex-dom+    , reflex >= 0.5 && < 0.7+    , reflex-dom >= 0.4 && < 0.6     , template-haskell+    , text   default-language:    Haskell2010   default-extensions:       TemplateHaskell
src/Reflex/Tags.hs view
@@ -28,4 +28,5 @@  import Reflex.Tags.TH -genTags+-- | generate all the tags with a suffix+genTagsSuffixed
src/Reflex/Tags/Attr.hs view
@@ -8,7 +8,7 @@ Stability   : experimental Portability : POSIX -This module is intended to be imported qualified.+This module is intended to be imported qualified. Allows you to use tags with a prefix.  This module exports all of the HTML tags for the 'elAttr' function. -}@@ -18,4 +18,4 @@ import Reflex.Tags.TH import Reflex.Dom.Widget -$(gen 'elAttr "")+genAttr ""
src/Reflex/Tags/AttrPrime.hs view
@@ -8,7 +8,7 @@ Stability   : experimental Portability : POSIX -This module is intended to be imported qualified.+This module is intended to be imported qualified. Allows you to use tags with a prefix.  This module exports all of the HTML tags for the 'elAttr\'' function. -}@@ -19,4 +19,4 @@ import Reflex.Tags.TH import Reflex.Dom.Widget -$(gen 'elAttr' "")+genAttr' ""
src/Reflex/Tags/DynAttr.hs view
@@ -8,7 +8,7 @@ Stability   : experimental Portability : POSIX -This module is intended to be imported qualified.+This module is intended to be imported qualified. Allows you to use tags with a prefix.  This module exports all of the HTML tags for the 'elDynAttr' function. -}@@ -18,4 +18,4 @@ import Reflex.Tags.TH import Reflex.Dom.Widget -$(gen 'elDynAttr "")+genDynAttr ""
src/Reflex/Tags/DynAttrPrime.hs view
@@ -8,7 +8,7 @@ Stability   : experimental Portability : POSIX -This module is intended to be imported qualified.+This module is intended to be imported qualified. Allows you to use tags with a prefix.  This module exports all of the HTML tags for the 'elDynAttr\'' function. -}@@ -18,4 +18,4 @@ import Reflex.Tags.TH import Reflex.Dom.Widget -$(gen 'elDynAttr' "")+genDynAttr' ""
src/Reflex/Tags/Simple.hs view
@@ -8,7 +8,7 @@ Stability   : experimental Portability : POSIX -This module is intended to be imported qualified.+This module is intended to be imported qualified. Allows you to use tags with a prefix.  This module exports all of the HTML tags for the 'el' function. -}@@ -20,4 +20,4 @@ import Reflex.Dom.Widget (el) import Reflex.Tags.TH -gen 'el ""+gen_ ""
+ src/Reflex/Tags/SimpleClass.hs view
@@ -0,0 +1,23 @@+{-|+Module      : Reflex.Tags.Simple+Description : reflex-dom simple tags+Copyright   : (c) Layer 3 Communications, 2016+                  Matthew Parsons, 2016+License     : BSD3+Maintainer  : parsonsmatt@gmail.com+Stability   : experimental+Portability : POSIX++This module is intended to be imported qualified. Allows you to use tags with a prefix.++This module exports all of the HTML tags for the 'el' function.+-}++module Reflex.Tags.SimpleClass where++import qualified Prelude as P++import Reflex.Dom.Widget (el)+import Reflex.Tags.TH++genClass ""
src/Reflex/Tags/SimplePrime.hs view
@@ -8,7 +8,7 @@ Stability   : experimental Portability : POSIX -This module is intended to be imported qualified.+This module is intended to be imported qualified. Allows you to use tags with a prefix.  This module exports all of the HTML tags for the 'el\'' function. -}@@ -19,4 +19,4 @@ import Reflex.Dom.Widget (el') import Reflex.Tags.TH -gen 'el' ""+gen' ""
src/Reflex/Tags/TH.hs view
@@ -12,12 +12,15 @@ elements. -} +{-# LANGUAGE OverloadedStrings #-}+ module Reflex.Tags.TH where  import Reflex.Dom.Widget import Control.Monad  import Language.Haskell.TH+import qualified Data.Text as Text  -- | A list of all HTML elements. elements :: [String]@@ -154,40 +157,51 @@         let name = mkName (element ++ suffix)         funD name [clause [] (normalB (appE (varE sym) (stringE element))) []] +elS = el . Text.pack+elS' = el' . Text.pack+elClassS = elClass . Text.pack+elAttrS = elAttr . Text.pack+elAttrS' = elAttr' . Text.pack+elDynAttrS = elDynAttr . Text.pack+elDynAttrS' = elDynAttr' . Text.pack+ -- | Generate 'el' functions for all of the elements with an @_@ suffix.-gen_ :: DecsQ-gen_ = gen 'el "_"+gen_ :: String -> DecsQ+gen_ = gen 'elS +genClass :: String -> DecsQ+genClass = gen 'elClassS+ -- | Generate 'el'' functions for all of the elements with an @'@ suffix.-gen' :: DecsQ-gen' = gen 'el' "'"+gen' :: String -> DecsQ+gen' = gen 'elS'  -- | Generate 'elAttr' functions for all of the elements with an @Attr@ suffix.-genAttr :: DecsQ-genAttr = gen 'elAttr "Attr"+genAttr :: String -> DecsQ+genAttr = gen 'elAttrS  -- | Generate 'elAttr'' functions for all of the elements with an @Attr'@ -- suffix.-genAttr' :: DecsQ-genAttr' = gen 'elAttr' "Attr'"+genAttr' :: String -> DecsQ+genAttr' = gen 'elAttrS'  -- | Generate 'elDynAttr' functions for all of the elements with a @DynAttr@ -- suffix.-genDynAttr :: DecsQ-genDynAttr = gen 'elDynAttr "DynAttr"+genDynAttr :: String -> DecsQ+genDynAttr = gen 'elDynAttrS --- | Generate 'elDynAttr'' functions for all of the elements with a @DynAttr'@--- suffix.-genDynAttr' :: DecsQ-genDynAttr' = gen 'elDynAttr' "DynAttr'"+-- | Generate all of the tags with all of the suffixes.+genDynAttr' :: String -> DecsQ+genDynAttr' = gen 'elDynAttrS'  -- | Generate all of the tags with all of the suffixes.-genTags :: DecsQ-genTags = do-    a <- gen_-    b <- gen'-    c <- genAttr-    d <- genAttr'-    e <- genDynAttr-    f <- genDynAttr'-    return (mconcat [a, b, c, d, e, f])+genTagsSuffixed :: DecsQ+genTagsSuffixed = do+    a <- gen_ "_"+    b <- gen' "'"+    c <- genAttr "Attr"+    d <- genAttr' "Attr'"+    e <- genDynAttr "DynAttr"+    f <- genDynAttr' "DynAttr'"+    g <- genClass "Class"+    return (mconcat [a, b, c, d, e, f, g])