Last active
November 14, 2016 02:49
-
-
Save kell18/c98b289e9b5b6389609daea9fb160b14 to your computer and use it in GitHub Desktop.
Valid code
This file contains 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
package cas.web.pages.templates | |
import cas.utils.Files | |
import scala.xml.Elem | |
object Templates { | |
def page(pathToStatic: String)(menuElements: List[Elem])(content: Elem) = <html> | |
<head> { Files.readFile(pathToStatic) } </head> | |
<body> | |
{ headerMenu(menuElements) } | |
{ centered(<span> { content } </span>) } | |
{ footer(<span> 2016, Content Analysis System </span>) } | |
</body> | |
</html> | |
def headerMenu(elements: List[Elem]) = <div class="menu"> | |
{ for (el <- elements) yield <span class="menu-item"> { el } </span> } | |
</div> | |
def centered(content: Elem) = <div class="allign-center"> { content } </div> | |
def footer(content: Elem) = <div class="footer"> { content } </div> | |
} | |
object Example { | |
import Templates._ | |
val defaultTemplate = page("static/head")(<a href="/home">Home</a> :: | |
<a href="/control">Control</a> :: | |
<a href="/about">About</a> :: Nil) (_) | |
val mainPage = defaultTemplate(<h1>Main page content</h1>) | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment