mirror of
https://github.com/byteverse/colonnade.git
synced 2024-10-26 08:03:25 +03:00
commit
8ed64f1d2b
@ -9,6 +9,7 @@ module Yesod.Colonnade
|
||||
, stringCell
|
||||
, textCell
|
||||
, builderCell
|
||||
, anchorCell
|
||||
) where
|
||||
|
||||
import Yesod.Core
|
||||
@ -18,6 +19,7 @@ import Control.Monad
|
||||
import Data.Monoid
|
||||
import Data.String (IsString(..))
|
||||
import qualified Colonnade.Encoding as Encoding
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.Lazy as LText
|
||||
import qualified Data.Text.Lazy.Builder as TBuilder
|
||||
|
||||
@ -45,6 +47,11 @@ textCell = cell . toWidget . toHtml
|
||||
builderCell :: TBuilder.Builder -> Cell site
|
||||
builderCell = cell . toWidget . toHtml . LText.toStrict . TBuilder.toLazyText
|
||||
|
||||
anchorCell :: (a -> Route site) -> (a -> WidgetT site IO ()) -> a -> Cell site
|
||||
anchorCell getRoute getContent a = cell $ do
|
||||
urlRender <- getUrlRender
|
||||
aTag [(Text.pack "href",urlRender (getRoute a))] (getContent a)
|
||||
|
||||
-- | This determines the attributes that are added
|
||||
-- to the individual @li@s by concatenating the header\'s
|
||||
-- attributes with the data\'s attributes.
|
||||
@ -99,7 +106,7 @@ widgetFromCell ::
|
||||
widgetFromCell f (Cell attrs contents) =
|
||||
f attrs contents
|
||||
|
||||
tr,tbody,thead,tableEl,td,th,ul,li ::
|
||||
tr,tbody,thead,tableEl,td,th,ul,li,aTag ::
|
||||
[(Text,Text)] -> WidgetT site IO () -> WidgetT site IO ()
|
||||
tableEl str b = [whamlet|
|
||||
<table *{str}>^{b}
|
||||
@ -125,4 +132,7 @@ ul str b = [whamlet|
|
||||
li str b = [whamlet|
|
||||
<li *{str}>^{b}
|
||||
|]
|
||||
aTag str b = [whamlet|
|
||||
<a *{str}>^{b}
|
||||
|]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user