The tag B
, defines a block and we'll just call it the block tag from now on. A block won't be shown in the generated HTML, it is completely stripped away. Its contents can however be assigned to a value tag. This is done from Java code with a call to setBlock
. In other words, a block can be thought of as a building block which can later be used to construct the page. In the guess
template there are several blocks defined, but only one of them is used at a time.
Example 4.2. Snippet from Guess.java that uses setBlock()
if (game.getAnswer() < guess) { mTemplate.setBlock("indication", "lower"); } else if (game.getAnswer() > guess) { mTemplate.setBlock("indication", "higher"); }
This piece of code from the Java implementation of the guess element shows how the lower
and higher
blocks are used together with the value placeholder indication
. Remember, the contents of a block only appears if it has been assigned to a value.