Consider the following scenario:
case class Outer(inner: Option[Inner])
case class Inner(a: String, b: String)
val data1 = Outer(Some(Inner("hello", "world")))
val data2 = Outer(None)
val context = Map("data1" -> data1, "data2" -> data2)
A template substitution {{ data1 }} renders Outer(Some(Inner(hello,world))) and a non-existent attribute one {{ data1.xyz }} renders an empty string. This is logical and one would expect this to be the case for all kinds of objects. However, {{ data1.inner.xyz }} doesn't render an empty string, but renders Inner(hello,world). Granted, {{ data1.inner._.xyz }} works correctly.
Here it is in scastie in a bit more detail: https://scastie.scala-lang.org/zV1Z62kMQIWwZ1TN9oAO8g
Is this an expected behavior or a bug? In general, it would be great to be able to not have to write ._ at the end of an Option,
Consider the following scenario:
A template substitution
{{ data1 }}rendersOuter(Some(Inner(hello,world)))and a non-existent attribute one{{ data1.xyz }}renders an empty string. This is logical and one would expect this to be the case for all kinds of objects. However,{{ data1.inner.xyz }}doesn't render an empty string, but rendersInner(hello,world). Granted,{{ data1.inner._.xyz }}works correctly.Here it is in scastie in a bit more detail: https://scastie.scala-lang.org/zV1Z62kMQIWwZ1TN9oAO8g
Is this an expected behavior or a bug? In general, it would be great to be able to not have to write
._at the end of an Option,