-- |
-- Module:     Data.CSS.Properties.Utils
-- Copyright:  (c) 2013 Ertugrul Soeylemez
-- License:    BSD3
-- Maintainer: Ertugrul Soeylemez <es@ertes.de>

module Data.CSS.Properties.Utils
    ( -- * Maybe builders
      maybeBuilder,
      maybeProp
    )
    where

import Blaze.ByteString.Builder
import Data.ByteString (ByteString)
import Data.CSS.Types


-- | Convenience wrapper around 'maybe' for properties.  Renders as the
-- given bytestring if 'Nothing'.

maybeBuilder :: (ToPropValue a) => ByteString -> Maybe a -> Builder
maybeBuilder str = maybe (fromByteString str) toPropBuilder


-- | Convenience wrapper around 'maybe' for properties.  Renders as the
-- given bytestring if 'Nothing'.

maybeProp :: (ToPropValue a) => ByteString -> Maybe a -> PropValue
maybeProp str = maybe (PropValue str) toPropValue