packages feed

yesod-sass (empty) → 0.1.0.0

raw patch · 4 files changed

+183/−0 lines, 4 filesdep +basedep +data-defaultdep +hsasssetup-changed

Dependencies added: base, data-default, hsass, shakespeare, template-haskell, text, yesod-core

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Felipe Garay++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Felipe Garay nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Text/Sass/QQ.hs view
@@ -0,0 +1,73 @@+{-# LANGUAGE TemplateHaskell #-}+-- | In this module there is a helper function called 'wsass''.  You need to use+-- it to define another function using 'wsass'' passing in the first argument+-- the path to be used to resolve @include like this:+--+-- >>> let wsass = wass' "sass_include/"+--+-- Please, check the install instructions of hlibsass at+-- <https://github.com/jakubfijalkowski/hlibsass>+--+module Text.Sass.QQ+    ( sass+    , wsass'+    ) where++import Prelude hiding (exp)+import Text.Sass+import Language.Haskell.TH+import Language.Haskell.TH.Quote+import Data.Default (def)+import Text.Lucius (toCss)+import qualified Data.Text as T+import Yesod.Core.Widget (toWidget, CssBuilder(..))++data Ctx = Pat | Type | Dec++qq :: String -> (String -> Q Exp) -> QuasiQuoter+qq name exp = QuasiQuoter { quoteExp = exp+                          , quotePat = error $ errorString Pat+                          , quoteType = error $ errorString Type+                          , quoteDec = error $ errorString Dec+                          }+    where+        errorString ctx = +            "You can't use the " ++ name ++ " quasiquoter in " ++ ctxName ctx++        ctxName Pat  = "a pattern"+        ctxName Type = "a type"+        ctxName Dec  = "a declaration"++++++-- | Quasiquoter that generate a string from Sass code+sass :: QuasiQuoter+sass = qq "sass" exp+    where+        exp :: String -> Q Exp+        exp str = do+            css <- runIO $ compileSass Nothing str+            [| $(stringE css) |]++-- | Quasiquoter that generate a yesod widget from Sass code+--+wsass' :: FilePath    -- ^ path of the sass files to use with @include+       -> QuasiQuoter+wsass' include = qq "wsass" exp+    where+        exp :: String -> Q Exp+        exp str = do+            css <- runIO $ compileSass (Just [include]) str+            [| toWidget $ CssBuilder $(stringE css) |]+++compileSass :: Maybe [FilePath] -> String -> IO String+compileSass include str = do+    result <- compileString str (def { sassIncludePaths = include } )+    case result of+        Left err -> do+            err' <- errorMessage err+            error err'+        Right compiled -> return . resultString $ compiled
+ yesod-sass.cabal view
@@ -0,0 +1,78 @@+-- Initial yesod-sass.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++-- The name of the package.+name:                yesod-sass++-- The package version.  See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary:      +-+------- breaking API changes+--                   | | +----- non-breaking API additions+--                   | | | +--- code changes with no API change+version:             0.1.0.0++-- A short (one-line) description of the package.+synopsis:            A simple quasiquoter to include sass code in yesod++-- A longer description of the package.+description:         This is a simple quasiquoter to include sass code in yesod.+                     You can use wsass to create a widget in the same way as+                     lucius.++-- The license under which the package is released.+license:             BSD3++-- The file containing the license text.+license-file:        LICENSE+++-- The package author(s).+author:              Felipe Garay++-- An email address to which users can send suggestions, bug reports, and +-- patches.+maintainer:          felipe.garay@usach.cl++-- A copyright notice.+copyright:           Felipe Garay++category:            Web++build-type:          Simple++-- Extra files to be distributed with the package, such as examples or a +-- README.+-- extra-source-files:  ++-- Constraint on the version of Cabal needed to build this package.+cabal-version:       >=1.10++source-repository head+  type:     git+  location: git@github.com:fgaray/yesod-sass.git++library+  -- Modules exported by the library.+  exposed-modules:     Text.Sass.QQ+  +  -- Modules included in this library but not exported.+  -- other-modules:       +  +  -- LANGUAGE extensions used by modules in this package.+  -- other-extensions:    +  +  -- Other library packages from which modules are imported.+  build-depends:       base >=4.7 && <4.8+                     , hsass >= 0.2 && < 0.3+                     , template-haskell+                     , data-default+                     , text+                     , shakespeare >= 2.0 && < 2.1+                     , yesod-core >= 1.4 && < 1.5+  +  -- Directories containing source files.+  hs-source-dirs:      src+  +  -- Base language which the package is written in.+  default-language:    Haskell2010