Skip to content

Instantly share code, notes, and snippets.

@ricsirigu
Last active July 11, 2019 10:40
Show Gist options
  • Save ricsirigu/75db204b4a481569a8ebb242182f59c6 to your computer and use it in GitHub Desktop.
Save ricsirigu/75db204b4a481569a8ebb242182f59c6 to your computer and use it in GitHub Desktop.
How to dynamically render HTML with Scala and the Lift framework
class ConditionalRendering{
def render: (NodeSeq) => NodeSeq = {
"#content-container" #> {if(trueness) PassThru else ClearNodes} andThen
"#inclusions" #> {".inclusions-text *" #> { List("food", "drinks") } }
}
}
<!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