{-# LANGUAGE OverloadedStrings #-} module Text.Digestive.Blaze.Html5 ( BlazeFormHtml , inputText , inputText' , inputHidden , inputHidden' , inputTextArea , inputTextArea' , inputTextRead , inputPassword , inputPassword' , inputCheckBox , inputRadio , inputFile , inputSelect , submit , label , errors , childErrors , inputList , inputListJs , module Text.Digestive.Forms.Html ) where import Control.Monad (forM_, unless, when) import Data.Maybe (fromMaybe) import Data.Monoid (mempty) import Data.String (IsString(..)) import Data.Text (Text) import Text.Blaze (Attribute) import Text.Blaze.Html5 (Html, (!), toValue, toHtml) import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A import Text.Digestive.Types import Text.Digestive.Forms (FormInput (..)) import qualified Text.Digestive.Forms as Forms import qualified Text.Digestive.Common as Common import Text.Digestive.Forms.Html -- | Form HTML generated by blaze -- type BlazeFormHtml = FormHtml Html -- | 'applyClasses' instantiated for blaze -- applyClasses' :: [FormHtmlConfig -> [String]] -- ^ Labels to apply -> FormHtmlConfig -- ^ Label configuration -> Html -- ^ HTML element -> Html -- ^ Resulting element applyClasses' = applyClasses $ \element value -> element ! A.class_ (toValue value) -- | Applies an attribute to some HTML, but only if an associated -- boolean value is true. attrWhenTrue :: Attribute -> Bool -> Html -> Html attrWhenTrue a True h = h ! a attrWhenTrue _ False h = h -- | Checks the input element when the argument is true checked :: Bool -> Html -> Html checked = attrWhenTrue (A.checked "checked") -- | Selects an @