bmc/scalasti — Issue #3: Problem with setAttribute and makeBeanAttribute
Author: bmc
Created: 2011-10-26 15:13:32+00:00
State: open
Labels: bug

Attached code fails.

```scala

import org.clapper.scalasti.StringTemplate

object ScalastiBug {
class SampleUser {
var firstName:String = null
var lastName:String = null

override def toString = firstName + " " + lastName
}

def main(args: Array[String]) {
val u1 = new SampleUser
u1.firstName = "Elvis"
u1.lastName = "Presley"

val u2 = new SampleUser
u2.firstName = "Frank"
u2.lastName = "Sinatra"

val users = u1 :: u2 :: Nil
println(users.getClass)

val t1 = "Hi $user.firstName$ $user.lastName$!"
System.out.println("T1: " + new StringTemplate(t1).makeBeanAttribute("user", u1).toString())

val t2 = """
$users:{
Hi $it.firstName$ $it.lastName$
}$
"""

System.out.println("Users: " + users)

try_one("Test 1") {
val st = new StringTemplate(t2)
st.makeBeanAttribute("users", users: _*)
System.out.println("T2: " + st.toString)
}

// try_one("Test 2") {
// val st = new StringTemplate(t2)
// st.setAttribute("users", users)
// System.out.println("T2: " + st.toString)
// }
}

def try_one(label: String)(code: => Unit) {
val prefix = ("*" * 10) + " " + label + ": "
println()
println(prefix + "Running")
println()
code
println()
}
}
```