简体   繁体   中英

Why template engine doest'n render

When I write this code bellow in my login.scala.html, only the words 'foo' are showed, in other words, 'bar' is never showed.

<body>
    @{
        <span>bar</span>
        if(true)
        {
            <span>foo</span>
        }
    }

    @{
        <span>bar</span>
        for(i <- numbers)
        {
            <span>bar</span>
            <span>i.toString()</span>
        }
    }
</body>

Someone knows why?

As you used the block statement, it returning the last expression.

For example (try it in REPL):

val a: Int = 10 
val b: Int = 20
{
a
b
}

Output:

res0: Int = 20

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM