packages feed

shakespeare-css 0.10.8 → 1.0.0

raw patch · 5 files changed

+50/−26 lines, 5 filesdep ~shakespearedep ~shakespeare-cssdep ~text

Dependency ranges changed: shakespeare, shakespeare-css, text

Files

Text/Cassius.hs view
@@ -42,7 +42,7 @@ import Language.Haskell.TH.Quote (QuasiQuoter (..)) import Language.Haskell.TH.Syntax import Language.Haskell.TH-import Data.Text.Lazy.Builder (fromText, fromLazyText)+import Data.Text.Lazy.Builder (fromLazyText) import Data.Maybe (catMaybes) import Data.Word (Word8) import Data.Bits
Text/Css.hs view
@@ -6,10 +6,12 @@ module Text.Css where  import Data.List (intersperse, intercalate)-import Data.Text.Lazy.Builder (Builder, fromText, singleton, toLazyText, fromLazyText, fromString)+import Data.Text.Lazy.Builder (Builder, singleton, toLazyText, fromLazyText, fromString) import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Builder as TLB import Data.Monoid (mconcat, mappend, mempty)-import Data.Text (Text, pack)+import Data.Text (Text)+import qualified Data.Text as T import Language.Haskell.TH.Syntax import System.IO.Unsafe (unsafePerformIO) import Text.ParserCombinators.Parsec (Parser, parse)@@ -18,6 +20,14 @@ import Control.Applicative ((<$>), (<*>)) import Control.Arrow ((***)) +pack :: String -> Text+pack = T.pack+{-# NOINLINE pack #-}++fromText :: Text -> Builder+fromText = TLB.fromText+{-# NOINLINE fromText #-}+ class ToCss a where     toCss :: a -> Builder @@ -29,7 +39,7 @@     { _cssSelectors :: Builder     , _cssAttributes :: [(Builder, Builder)]     }-data CssTop = AtBlock String Builder [Css'] | Css Css' | AtDecl String String+data CssTop = AtBlock String Builder [Css'] | Css Css' | AtDecl String Builder  type Css = [CssTop] @@ -65,14 +75,14 @@   where     go :: [TopLevel] -> ([(String, String)], [Content])     go [] = ([], [])-    go (TopAtDecl dec cs:rest) =+    go (TopAtDecl dec _FIXMEcs:rest) =         (scope, rest'')       where         (scope, rest') = go rest         rest'' = ContentRaw (concat             [ "@"             , dec-            , cs+            -- FIXME, cs             , ";"             ]) : rest'     go (TopAtBlock _ _ blocks:rest) =@@ -155,7 +165,10 @@   where     goTop :: [(String, String)] -> [TopLevel] -> Css     goTop _ [] = []-    goTop scope (TopAtDecl dec cs:rest) = AtDecl dec cs : goTop scope rest+    goTop scope (TopAtDecl dec cs':rest) =+        AtDecl dec cs : goTop scope rest+      where+        cs = either error mconcat $ mapM (contentToBuilderRT cd render') cs'     goTop scope (TopBlock b:rest) =         map Css (either error ($[]) $ blockRuntime (addScope scope) render' b) ++         goTop scope rest@@ -210,7 +223,7 @@                     , _atBlockSelector :: Contents                     , _atBlockInner :: [Block]                     }-              | TopAtDecl String String+              | TopAtDecl String Contents               | TopVar String String  type Pairs = [Pair]@@ -287,7 +300,7 @@         es <- go r scope rest         return $ e : es     go r scope (TopAtDecl dec cs:rest) = do-        e <- [|(:) $ AtDecl $(lift dec) $(lift cs)|]+        e <- [|(:) $ AtDecl $(lift dec) $(contentsToBuilder r scope cs)|]         es <- go r scope rest         return $ e : es     go r scope (TopVar k v:rest) = go r ((k, v) : scope) rest@@ -307,7 +320,7 @@         singleton '{' `mappend`         foldr mappend (singleton '}') (map renderCss' x)     go (AtDecl dec cs) = fromText (pack $ concat ["@", dec, " "]) `mappend`-                      fromText (pack cs) `mappend`+                      cs `mappend`                       singleton ';'  renderCss' :: Css' -> Builder
Text/Lucius.hs view
@@ -21,7 +21,7 @@ import Text.Shakespeare.Base import Language.Haskell.TH.Quote (QuasiQuoter (..)) import Language.Haskell.TH.Syntax-import Data.Text (Text, pack, unpack)+import Data.Text (Text, unpack) import qualified Data.Text.Lazy as TL import Text.ParserCombinators.Parsec hiding (Line) import Text.Css@@ -30,12 +30,11 @@ import Control.Applicative ((<$>)) import Control.Monad (when) import Data.Either (partitionEithers)-import Data.Text.Lazy.Builder (fromText) import Data.Monoid (mconcat)  -- | ----- >>> renderLucius undefined [lucius|foo{bar:baz}|]+-- >>> renderCss ([lucius|foo{bar:baz}|] undefined) -- "foo{bar:baz}" lucius :: QuasiQuoter lucius = QuasiQuoter { quoteExp = luciusFromString }@@ -179,7 +178,7 @@         return tl     charset = do         try $ stringCI "@charset "-        cs <- many1 $ noneOf ";"+        cs <- parseContents ";"         _ <- char ';'         return $ TopAtDecl "charset" cs     media = do@@ -190,7 +189,7 @@         return $ TopAtBlock "media" selector b     impor = do         try $ stringCI "@import ";-        val <- many1 $ noneOf ";";+        val <- parseContents ";"         _ <- char ';'         return $ TopAtDecl "import" val     var = try $ do@@ -222,9 +221,12 @@   where     go :: [(Text, Text)] -> [TopLevel] -> Either String Css     go _ [] = Right []-    go scope (TopAtDecl dec cs:rest) = do+    go scope (TopAtDecl dec cs':rest) = do+        let scope' = map goScope scope+            render = error "luciusRT has no URLs"+        cs <- mapM (contentToBuilderRT scope' render) cs'         rest' <- go scope rest-        Right $ AtDecl dec cs : rest'+        Right $ AtDecl dec (mconcat cs) : rest'     go scope (TopBlock b:rest) = do         b' <- goBlock scope b         rest' <- go scope rest
shakespeare-css.cabal view
@@ -1,5 +1,5 @@ name:            shakespeare-css-version:         0.10.8+version:         1.0.0 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -12,12 +12,12 @@     .     This package contains 2 css template languages. The Cassius language uses whitespace to avoid the need for closing brackets and semi-colons. Lucius does not care about whitespace and is a strict superset of css. There are also some significant conveniences added for css.     .-    Please see http://docs.yesodweb.com/book/templates for a more thorough description and examples+    Please see http://www.yesodweb.com/book/shakespearean-templates for a more thorough description and examples category:        Web, Yesod stability:       Stable cabal-version:   >= 1.8 build-type:      Simple-homepage:        http://www.yesodweb.com/book/templates+homepage:        http://www.yesodweb.com/book/shakespearean-templates extra-source-files:   test/cassiuses/external1.cassius   test/cassiuses/external1.lucius@@ -30,11 +30,11 @@  library     build-depends:   base             >= 4       && < 5-                   , shakespeare      >= 0.10    && < 0.12+                   , shakespeare      >= 1.0     && < 1.1                    , template-haskell-                   , text             >= 0.7     && < 0.12-                   , process          >= 1.0     && < 1.2-                   , parsec           >= 2       && < 4+                   , text             >= 0.11.1.1 && < 0.12+                   , process          >= 1.0      && < 1.2+                   , parsec           >= 2        && < 4      exposed-modules: Text.Cassius                      Text.Lucius@@ -50,8 +50,8 @@     type: exitcode-stdio-1.0      ghc-options:   -Wall-    build-depends: shakespeare-css  >= 0.10    && < 0.11-                 , shakespeare      >= 0.10    && < 0.12+    build-depends: shakespeare-css+                 , shakespeare                  , base             >= 4       && < 5                  , HUnit                  , hspec            >= 0.8     && < 0.10
test/ShakespeareCssTest.hs view
@@ -339,6 +339,15 @@ @mobileWidth: 400px;
 @media (max-width: #{mobileWidth}){ foo { color: red; } }
 |]
+  , it "URLs in import" $ celper
+        "@import url(\"suburl\");" [lucius|
+@import url("@{Sub SubUrl}");
+|]
+  , let charset = "mycharset"
+     in it "vars in charset" $ celper
+        "@charset mycharset;" [lucius|
+@charset #{charset};
+|]
   ]
 
 data Url = Home | Sub SubUrl