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
-- hello.ssp | |
hello <%= first %> <%= last %> | |
-- Hello.scala | |
case class Person(first: String, last: String) | |
class MyTemplates { | |
@template("hello.ssp") |
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
def bar(body:() => String) { println("start"); body(); println("end") } | |
bar { | |
println("outside of bar") | |
var a ="Hello" | |
var b = "World" | |
() => { | |
println("inside of bar") | |
a+b | |
} |
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
def mytag(body: => Unit) = { | |
val context = RenderContext() | |
val text = context.capture(body) | |
println("Evaluated text: " + text) | |
context << ("<h3>Wrapped body</h3><p>" + text + "</p><h3>End of wrapped body</h3>") | |
} |
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
def mytag(body: => Unit) = { | |
import RenderContext() | |
val text = capture(body) | |
println("Evaluated text: " + text) | |
<< ("<h3>Wrapped body</h3><p>" + text + "</p><h3>End of wrapped body</h3>") | |
} |
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
<html> | |
<head> | |
<title>My Title</title> | |
</head> | |
<body> | |
<div id="header">Header</div> | |
<div id="content"> | |
<table class="people"> | |
<tr> |
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
object transformer extends Transformer { | |
$(".people") { node => | |
val even = $(".person even").remove | |
val odd = $(".person odd").remove | |
val person_transform = new Transformer { | |
$(".name").contents = p.name | |
$(".location").contents = p.location | |
} |
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
object transformer extends Transformer { | |
$(".people") { node => | |
// extract a template fragment from the html.. removes it | |
val odd = node.$template("tr.odd") | |
val even = node.$template("tr.even") | |
var c=0 | |
people.flatMap { p => | |
c += 1 | |
node << transform(if (c%2 == 0) even else odd) { t => | |
$(".name").contents = p.name |
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
<html> | |
<ul class="items"> | |
<li class="car"> | |
<img src="/images/car.jpg"/> | |
<div class="field"><div class="label">Make</div><div class="make">BMW</div></div> | |
<div class="field"><div class="label">Model</div><div class="model">525i</div></div> | |
<div class="field"><div class="label">Color</div><div class="color">Blue</div></div> | |
</li> | |
<li class="dog"> | |
<img src="/images/dog.jpg"/> |
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
object transformer extends Transformer { | |
$(".people").contents { | |
people.flatMap { p => | |
transform($("li:first-child")) { | |
$("a.person").contents = p.name | |
$("a.person").attribute("href").value = "http://acme.com/bookstore/" + p.name | |
} | |
} | |
} | |
} |
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
table.hl | |
margin: 2em 0 | |
td.ln | |
text-align: right | |
==================================== | |
table.hl { |
OlderNewer