IHP Api Reference
Copyright(c) digitally induced GmbH 2020
Safe HaskellNone

IHP.View.Classes

Description

 
Synopsis

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>

Orphan instances

IsString (Text, Bool) Source #

Allows `("my-class", True)` to be written as `"my-class"`

Useful together with classes

Instance details

Methods

fromString :: String -> (Text, Bool) #