| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
MathiasSM.Context.Data
Description
Generic data files: any YAML under contentdata, exposed to templates.
Each file becomes a template context named after its path (directories joined
with -, extension dropped). A file holding a top-level list is looped with
$for(name)$; a top-level map is read with $name.key$ (nested maps flatten
to dotted keys). Scalars render as strings.
A list item with _show: false is left out of the loop entirely.
Any scalar field whose name contains icon also gets two derived fields:
fieldHref (the icon URL) and fieldRaw (the SVG markup, inlined).
Synopsis
- dataContext :: SiteConfig -> Context a
- renderScalar :: Value -> String
- scalarString :: Value -> Maybe String
- iconName :: Value -> Maybe String
- lookupLeaf :: String -> Value -> Maybe Value
- isShown :: Value -> Bool
- nameToRelPath :: String -> FilePath
- breakOnDot :: String -> (String, String)
- iconVariant :: String -> Maybe (String, IconVariant)
- data IconVariant
- checkAgainstSchema :: Value -> Value -> Either [String] ()
Documentation
dataContext :: SiteConfig -> Context a Source #
A dynamic context for every data file under dataDir
Pure helpers (also used by the tests)
renderScalar :: Value -> String Source #
A scalar as the string templates should see
lookupLeaf :: String -> Value -> Maybe Value Source #
The dotted path of a scalar leaf inside a value, if any
isShown :: Value -> Bool Source #
Whether a list item should appear: only an explicit _show: false hides it
nameToRelPath :: String -> FilePath Source #
The file name (directories joined with -) is a path relative to dataDir
breakOnDot :: String -> (String, String) Source #
The key up to the first dot, and the dotted path after it
iconVariant :: String -> Maybe (String, IconVariant) Source #
data IconVariant Source #
Instances
| Show IconVariant Source # | |
Defined in MathiasSM.Context.Data Methods showsPrec :: Int -> IconVariant -> ShowS # show :: IconVariant -> String # showList :: [IconVariant] -> ShowS # | |
| Eq IconVariant Source # | |
Defined in MathiasSM.Context.Data | |