sumi

Basics · Logic

For loops

{for … range …}…{/for} repeats markup once per item. Everything between {for and the end of the clause is a real Go range clause, so a signal holding a slice reads with .Get() there, and both the index and value bindings are in scope in the body.

The script below holds a Task type and a signal with three of them. So far the template only reports the count.

Your turn

Render the list. Inside the <ul>, add a loop over the tasks:

{for _, task := range tasks.Get()}
    <li>{task.Title}</li>
{/for}

task is an ordinary loop variable, not a signal, so {task.Title} reads directly — no .Get(). Press Run and the list appears. Solve shows the finished version; Reset restores the start.

⌘↵ to run