Basics · Composition
Snippet arguments
A snippet can take parameters, so one declaration renders differently on
each call. The parameters are ordinary Go — you name them in the
{snippet …()} header and use them in the body.
The tag from the last lesson always reads todo. We can make it show a
label passed at each call site instead.
Your turn
Give the snippet a string parameter and use it:
{snippet tag(label string)}<div class="tag">— {label} —</div>{/snippet}
{label} is a plain parameter, not a signal, so it does not need
.Get(). Now pass a label at each call: {render tag("buy milk")} and
{render tag("write tutorial")}.
Press Run; each tag shows its own text. Solve shows the finished version; Reset restores the start.