ReferenceconditionalContent

<conditionalContent>

Renders content conditionally based on its `<case>` or `<else>` children

<conditionalContent> is a General Operator component that defines one or more blocks of content that are evaluated only when certain conditions are met. Conditions may be defined directly on the <conditionalContent> tag using the condition attribute.
Alternatively, one can use one or more <case> children with an optional <else> child.

Attributes and Properties

Attributes for <conditionalContent>

Other (1)

boolean. Convenience for a single-case form: the boolean condition for which the children are rendered.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <conditionalContent name="c">

Common to all components (4)
$c.doenetML

text. The DoenetML source code that produced this component.

$c.hide

boolean. Whether to hide this component from the rendered output.

$c.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$c.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: <conditionalContent> with nested <case> children

The <conditionalContent> component defines a block of content containing individual <case> children. The doenetML within each <case> is only rendered when its specified condition is true.


Example: <conditionalContent> with nested <else>

The <conditionalContent> component defines a block of content containing individual <case> children. To catch all remaining cases following a given condition or set of conditions, the <else> component may be used.

Attribute Examples

Attribute Example: condition

A <conditionalContent> block with a <condition> attribute renders only when the condition is satisfied. This allows for use of a <conditionalContent> component without nested <case> components.