Conditionally renders its body. May render its tag and any informal parameters.
| Name | Type | Flags | Default | Default Prefix | Since | Description |
|---|---|---|---|---|---|---|
| else | Block | NOT Allow Null | literal | An alternate Block to render if AbstractConditional#test() is false. The default, null, means render nothing in that situation. | ||
| negate | boolean | NOT Allow Null | prop | Optional parameter to invert the test. If true, then the body is rendered when the test parameter is false (not true). | ||
| test | boolean | Required, NOT Allow Null | prop | If true, then the body of the If component is rendered. If false, the body is omitted. |
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<body>
<h1>Welcome!</h1>
<t:if test="user">
Welcome back, ${user.firstName}
<p:else>
<t:pagelink name="login">Login</t:pagelink> /
<t:pagelink name="register">Register</t:pagelink>
</p:else>
</t:if>
. . .
</html>p:
namespace (new in Tapestry 5.1). In 5.0, this would be
<t:parameter name="else">.
Tapestry has many builtin coercions to boolean: