shakespeare-css 1.0.6 → 1.0.6.1
raw patch · 4 files changed
+22/−4 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Text/Css.hs +13/−3
- shakespeare-css.cabal +2/−1
- test/ShakespeareCssTest.hs +6/−0
- test/cassiuses/mixin.lucius +1/−0
Text/Css.hs view
@@ -95,11 +95,12 @@ | ContentVar Deref | ContentUrl Deref | ContentUrlParam Deref+ | ContentMixin Deref deriving (Show, Eq) type Contents = [Content] -data VarType = VTPlain | VTUrl | VTUrlParam+data VarType = VTPlain | VTUrl | VTUrlParam | VTMixin deriving Show data CDData url = CDPlain Builder@@ -155,12 +156,13 @@ where (scope1, rest1) = go (map TopBlock blocks) (scope2, rest2) = go rest- go (TopBlock (Block x y z _mixins):rest) =- (scope1 ++ scope2, rest0 ++ rest1 ++ rest2)+ go (TopBlock (Block x y z mixins):rest) =+ (scope1 ++ scope2, rest0 ++ rest1 ++ rest2 ++ restm) where rest0 = intercalate [ContentRaw ","] x ++ concatMap go' y (scope1, rest1) = go (map (TopBlock . snd) z) (scope2, rest2) = go rest+ restm = map ContentMixin mixins go (TopVar k v:rest) = ((k, v):scope, rest') where@@ -254,6 +256,7 @@ Just (CDUrlParam (u, p)) -> Right $ fromText $ render' u p _ -> Left $ show d ++ ": expected CDUrlParam"+contentToBuilderRT _ _ ContentMixin{} = Left "contentToBuilderRT ContentMixin" cssRuntime :: Bool -- ^ i2b? -> Parser [TopLevel Unresolved]@@ -297,6 +300,7 @@ c VTPlain = [|CDPlain . toCss|] c VTUrl = [|CDUrl|] c VTUrlParam = [|CDUrlParam|]+ c VTMixin = [|CDMixin|] getVars :: Monad m => [(String, String)] -> Content -> m [(Deref, VarType)] getVars _ ContentRaw{} = return []@@ -312,6 +316,10 @@ case lookupD d scope of Nothing -> return [(d, VTUrlParam)] Just s -> fail $ "Expected URLParam for " ++ s+getVars scope (ContentMixin d) =+ case lookupD d scope of+ Nothing -> return [(d, VTMixin)]+ Just s -> fail $ "Expected Mixin for " ++ s lookupD :: Deref -> [(String, b)] -> Maybe String lookupD (DerefIdent (Ident s)) scope =@@ -409,6 +417,7 @@ contentToBuilder r _ (ContentUrlParam u) = [|fromText|] `appE` ([|uncurry|] `appE` varE r `appE` return (derefToExp [] u))+contentToBuilder _ _ ContentMixin{} = error "contentToBuilder on ContentMixin" type Scope = [(String, String)] @@ -524,6 +533,7 @@ lift (ContentVar d) = [|ContentVar d|] lift (ContentUrl d) = [|ContentUrl d|] lift (ContentUrlParam d) = [|ContentUrlParam d|]+ lift (ContentMixin m) = [|ContentMixin m|] instance Lift (Block Unresolved) where lift (Block a b c d) = [|Block a b c d|] instance Lift (Block Resolved) where
shakespeare-css.cabal view
@@ -1,5 +1,5 @@ name: shakespeare-css-version: 1.0.6+version: 1.0.6.1 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -25,6 +25,7 @@ test/cassiuses/external2.lucius test/cassiuses/external-media.lucius test/cassiuses/external-nested.lucius+ test/cassiuses/mixin.lucius test/ShakespeareCssTest.hs test.hs
test/ShakespeareCssTest.hs view
@@ -444,6 +444,12 @@ True [(TS.pack "bins", RTVMixin bins)] + it "luciusFileReload mixin" $ do + let mixin = [luciusMixin|foo:bar;baz:bin|] + flip celper $(luciusFileReload "test/cassiuses/mixin.lucius") $ concat + [ "selector {\n foo: bar;\n baz: bin;\n}\n" + ] + it "& subblocks" $ celper "foo:bar{baz:bin}" [lucius|
+ test/cassiuses/mixin.lucius view
@@ -0,0 +1,1 @@+selector{^{mixin}}