Skip to content

Instantly share code, notes, and snippets.

@robertberry-zz
Created November 16, 2012 16:15
Show Gist options
  • Save robertberry-zz/4088610 to your computer and use it in GitHub Desktop.
Save robertberry-zz/4088610 to your computer and use it in GitHub Desktop.
package code
package snippet
import code.model.User
import scala.xml.{NodeSeq, Text}
import net.liftweb.util._
import net.liftweb.common._
import code.lib._
import Helpers._
class HomePage {
def summary(html: NodeSeq): NodeSeq = User.currentUser match {
case Full(user) => {
val entries: NodeSeq = user.allAccounts match {
case Nil => Text("You have no accounts.")
case accounts => accounts.flatMap({account =>
bind("acct", chooseTemplate("account", "entry", html),
"name" -> <a href={"/account/" + account.name.is}>
{account.name.is}</a>,
"balance" -> Text(account.balance.toString))
})
}
bind("account", html, "entry" -> entries)
}
case _ => <lift:embed what="welcome_message" />
}
def test = "#test *" #> <p>Whut</p>
}
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Home</title>
</head>
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
<h2>Home</h2>
<span class="lift:homePage.test">
<span id="test">test span</span>
</span>
<lift:homePage.summary>
<div class="column span-24 bordered">
<h3>Summary of accounts:</h3>
<account:entry>
<account:name />: <account:balance /> <br />
</account:entry>
</div>
</lift:homePage.summary>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Home</title>
</head>
<body class="lift:content_id=main">
<div id="main" class="lift:surround?with=default;at=content">
<h2>Home</h2>
<span class="lift:homePage.test">
<span id="test">test span</span>
</span>
<div class="lift:homePage.summary">
<div class="column span-24 bordered">
<h3>Summary of accounts:</h3>
<account:entry>
<account:name />: <account:balance /> <br />
</account:entry>
</div>
</div>
</div>
</body>
</html>
@robertberry-zz
Copy link
Author

The error message:

Error processing snippet: homepage.summary
Reason: Class Not Found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment