Current state
I have a collection of objects, this is working:
@LmlAction("blocks")
public Array<Block> getBlocks() {
return level.blocks;
}
<:foreach element="$blocks">
<textbutton color="red">{element}</textbutton>
</:foreach>
public class Block {
public boolean isWritten = false;
@Override
public String toString() {
return isWritten ? "x" : " ";
}
}

Goal
I'd like to colorize "x" blocks to red based on isWritten field.
Problem
Accessing the isWritten field is the unknown to me. How do I do that?
I thought about 2 ways:
- pass the
element (or index) to a method to evaluate it
- access the field directly from the template which doesn't work for me:
<:foreach element="$blocks">
<textbutton color="red">{element.isWritten}</textbutton>
</:foreach>