Copyright | (c) digitally induced GmbH 2020 |
---|---|
Safe Haskell | None |
Documentation
classes :: [(Text, Bool)] -> Text Source #
Helper for dynamically generating the class=".."
attribute.
Given a list like
[("a", True), ("b", False), ("c", True)]
builds a class name string for all parts where the second value is True
.
E.g.
>>>
classes [("a", True), ("b", False), ("c", True)]
"a c"
When setting b
to True
:
>>>
classes [("a", True), ("b", True), ("c", True)]
"a b c"
Example:
>>>
<div class={classes [("is-active", False)]}>
<div class="">
>>>
<div class={classes [("is-active", True)]}>
<div class="is-active">
>>>
forEach projects \project -> [hsx|
>>>
<div class={classes [("project", True), ("active", project.active)]}>
>>>
{project}
>>>
</div>
>>>
|]
If project is active: <div class="project active">{project}</div> Otherwise: <div class="project">{project}</div>