shakespeare 2.0.2.2 → 2.0.3
raw patch · 4 files changed
+50/−2 lines, 4 files
Files
- ChangeLog.md +4/−0
- Text/Cassius.hs +32/−0
- shakespeare.cabal +1/−1
- test/Text/Shakespeare/CssSpec.hs +13/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+### 2.0.3++* `cassiusMixin` added+ ### 2.0.2.2 GHC 7.10 support
Text/Cassius.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleInstances #-}@@ -17,6 +18,9 @@ , cassiusFile , cassiusFileDebug , cassiusFileReload+ -- ** Mixims+ , cassiusMixin+ , Mixin -- * ToCss instances -- ** Color , Color (..)@@ -66,3 +70,31 @@ -- creating systems like yesod devel. cassiusUsedIdentifiers :: String -> [(Deref, VarType)] cassiusUsedIdentifiers = cssUsedIdentifiers True Text.Lucius.parseTopLevels++-- | Create a mixin with Cassius syntax.+--+-- Since 2.0.3+cassiusMixin :: QuasiQuoter+cassiusMixin = QuasiQuoter+ { quoteExp = quoteExp Text.Lucius.luciusMixin . i2bMixin+ }++i2bMixin :: String -> String+i2bMixin s' =+ TL.unpack+ $ stripEnd "}"+ $ stripFront "mixin {"+ $ TL.strip+ $ TL.pack+ $ i2b+ $ unlines+ $ "mixin" : (map (" " ++) $ lines s')+ where+ stripFront x y =+ case TL.stripPrefix x y of+ Nothing -> y+ Just z -> z+ stripEnd x y =+ case TL.stripSuffix x y of+ Nothing -> y+ Just z -> z
shakespeare.cabal view
@@ -1,5 +1,5 @@ name: shakespeare-version: 2.0.2.2+version: 2.0.3 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>
test/Text/Shakespeare/CssSpec.hs view
@@ -399,7 +399,7 @@ } } |] - it "mixins" $ do + it "lucius mixins" $ do let bins = [luciusMixin| bin:bin2; /* FIXME not currently implementing sublocks in mixins @@ -410,6 +410,18 @@ |] :: Mixin -- No sublocks celper "foo{bar:baz;bin:bin2}foo foo2{x:y}" [lucius| celper "foo{bar:baz;bin:bin2}" [lucius| + foo { + bar: baz; + ^{bins} + } + |] + it "cassius mixins" $ do + let bins = [cassiusMixin| + bin:bin2 + bin3:bin4 + |] :: Mixin + -- No sublocks celper "foo{bar:baz;bin:bin2}foo foo2{x:y}" [lucius| + celper "foo{bar:baz;bin:bin2;bin3:bin4}" [lucius| foo { bar: baz; ^{bins}