I am working on a project using Heist, and since it recently upgrade to 0.13 version, I tried it out and find the original HeistConfig changed a lot.
data HeistConfig m = HeistConfig
{ hcInterpretedSplices :: Splices (I.Splice m)
-- ^ Interpreted splices are the splices that Heist has always had. They
-- return a list of nodes and are processed at runtime.
, hcLoadTimeSplices :: Splices (I.Splice IO)
-- ^ Load time splices are like interpreted splices because they return a
-- list of nodes. But they are like compiled splices because they are
-- processed once at load time. All of Heist's built-in splices should be
-- used as load time splices.
, hcCompiledSplices :: Splices (C.Splice m)
-- ^ Compiled splices return a DList of Chunks and are processed at load
-- time to generate a runtime monad action that will be used to render the
-- template.
, hcAttributeSplices :: Splices (AttrSplice m)
-- ^ Attribute splices are bound to attribute names and return a list of
-- attributes.
, hcTemplateLocations :: [TemplateLocation]
-- ^ A list of all the locations that Heist should get its templates
}
So now I could no longer use [] as default Splices, since there are defaultInterpretedSplices and defaultLoadTimeSplices, I find the defaultAttrSplices just missed, so how shoud I define it?
I think there are no built-in AttrSplices. You should be able to bind no splices using one of mempty
, return ()
or noSplices
from Heist.SpliceAPI
.
Splices s
is a type alias for SplicesM s ()
, which is just a State
wrapped in newtype.
Slices s
is also instance of Monoid type class so you can use mempty here.
newtype SplicesM s a = SplicesM { unSplices :: State (Map Text s) a }
deriving (Monad, MonadState (Map Text s))
type Splices s = SplicesM s ()
instance Monoid (Splices s) where
mempty = noSplices
mappend = unionWithS (\_ b -> b)