hakyll-sass (empty) → 0.1.0
raw patch · 4 files changed
+84/−0 lines, 4 filesdep +basedep +data-default-classdep +hakyllsetup-changed
Dependencies added: base, data-default-class, hakyll, hsass
Files
- LICENSE +20/−0
- Setup.hs +2/−0
- hakyll-sass.cabal +25/−0
- src/Hakyll/Web/Sass.hs +37/−0
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 Braden Walters++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hakyll-sass.cabal view
@@ -0,0 +1,25 @@+name: hakyll-sass+version: 0.1.0+synopsis: Hakyll SASS compiler over hsass+license: MIT+license-file: LICENSE+homepage: https://github.com/meoblast001/hakyll-sass+author: Braden Walters+maintainer: vc@braden-walters.info+category: Web+build-type: Simple+cabal-version: >= 1.10++description:+ Hakyll compiler which indirectly uses libsass to compile SASS and SCSS to CSS.+ The Ruby SASS compiler is not required.++library+ exposed-modules: Hakyll.Web.Sass+ build-depends:+ base >= 4 && < 5+ , hakyll >= 4.7.0+ , data-default-class >= 0.0.1+ , hsass >= 0.2.0+ hs-source-dirs: src+ default-language: Haskell2010
+ src/Hakyll/Web/Sass.hs view
@@ -0,0 +1,37 @@+-- |+-- Module: Hakyll.Web.Sass+-- Copyright: (C) 2015 Braden Walters+-- License: MIT (see LICENSE file)+-- Maintainer: Braden Walters <vc@braden-walters.info>+-- Stability: experimental+-- Portability: ghc++module Hakyll.Web.Sass (sassCompiler) where++import Data.Default.Class+import Data.Functor+import Hakyll.Core.Compiler+import Hakyll.Core.Item+import System.IO.Unsafe+import Text.Sass.Compilation+import Text.Sass.Options++-- | Compiles a SASS file into CSS.+sassCompiler :: Compiler (Item String)+sassCompiler = do+ bodyStr <- itemBody <$> getResourceBody+ extension <- getUnderlyingExtension+ let mayOptions = selectFileType def extension+ case mayOptions of+ Just options -> do+ resultOrErr <- unsafeCompiler (compileString bodyStr options)+ case resultOrErr of+ Left sassError -> fail (unsafePerformIO $ errorMessage sassError)+ Right result -> makeItem result+ Nothing -> fail "File type must be .scss or .sass."++-- | Use the file extension to determine whether to use indented syntax.+selectFileType :: SassOptions -> String -> Maybe SassOptions+selectFileType options ".scss" = Just $ options { sassIsIndentedSyntax = False }+selectFileType options ".sass" = Just $ options { sassIsIndentedSyntax = True }+selectFileType _ _ = Nothing