Best viewed on desktop Mobile Friendly tutorial coming soon!
Filtering & Polish
The classic TodoMVC finish: filter by All / Active / Completed, an empty state, and a strike-through on done items.
Filtering is just another piece of derived state. Keep a filter
variable and derive the list you actually render from it — the full
todos stays intact underneath:
<let/filter="all"><const/shown=applyFilter(todos, filter)>
<for|todo| of=shown by="id"> ... </for>The filter buttons set filter; the <for> loops shown instead of
todos. An <if> covers the empty case, and the item component strikes
through completed text with a derived inline style.
Finish it:
- Add a
<let/filter="all">and anapplyFilterhelper, derive<const/shown=...>, and loop it instead oftodos. - Wire the All / Active / Completed buttons to set
filter. - Add an
<if=(shown.length === 0)>empty message. - In
todo-item.marko, strike through the text wheninput.todo.done— a derivedstyle.
That’s TodoMVC — child components, two-way communication, dynamic lists, and derived filtering — and the end of Part 7. You’ve assembled a real app entirely from the pieces the earlier parts gave you.
Files
Preparing Environment
- Installing dependencies
- Starting dev server