You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, during my migration from jtwig to pebble I've noticed some odd behaviour: sometimes newlines are trimmed. Here is a test case to reproduce the issue:
import com.mitchellbosecke.pebble.PebbleEngine
import org.junit.jupiter.api.Test
import java.io.StringWriter
import java.io.Writer
class PebbleTest {
val template = """
<!DOCTYPE html>
<html>
<script>
const foo = {{ foo | default("null") }}
const bar = {{ bar | default("null") }};
</script>
</html>
""".trimIndent()
@Test
fun `no newline`() {
val pebble = PebbleEngine.Builder().build()
val template = pebble.getLiteralTemplate(template)
val writer: Writer = StringWriter()
template.evaluate(writer)
println(writer.toString())
}
}
It seems that the presence of the ; after the const bar definition means a semicolon will be inserted correctly. If I add one to the end of the const foo line the program behaves correctly.
(It's probably invalid JS to skip the semicolons... my fix was just to insert them. But the behaviour seemed unexpected to me!)
The text was updated successfully, but these errors were encountered:
Hi, during my migration from jtwig to pebble I've noticed some odd behaviour: sometimes newlines are trimmed. Here is a test case to reproduce the issue:
What I expect is:
But what I get is:
It seems that the presence of the
;
after theconst bar
definition means a semicolon will be inserted correctly. If I add one to the end of theconst foo
line the program behaves correctly.(It's probably invalid JS to skip the semicolons... my fix was just to insert them. But the behaviour seemed unexpected to me!)
The text was updated successfully, but these errors were encountered: