Last active
July 11, 2019 10:40
-
-
Save ricsirigu/75db204b4a481569a8ebb242182f59c6 to your computer and use it in GitHub Desktop.
How to dynamically render HTML with Scala and the Lift framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConditionalRendering{ | |
def render: (NodeSeq) => NodeSeq = { | |
"#content-container" #> {if(trueness) PassThru else ClearNodes} andThen | |
"#inclusions" #> {".inclusions-text *" #> { List("food", "drinks") } } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Your Snippet</title> | |
</head> | |
<body data-lift="ConditionalRendering"> | |
<div id="content-container"> | |
<span class="subtitle">Inclusions</span> | |
<div class="info"> | |
<ul id="inclusions"> | |
<li class="inclusions-text">Guided tour</li> | |
</ul> | |
</div> | |
</div> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment