carlos / todomvc-bakeoff Public

Clone
git clone https://amadan.net/carlos/todomvc-bakeoff

Plain git — no account needed to clone.

Download

Download this file

1## HTML rendering. The markup is TodoMVC's own template (shared/reference.html)
2## plus the forms and links that make it work without JavaScript.
3
4import std/xmltree
5import store
6
7type View* = object
8 todos*: seq[Todo] ## the items the filter shows
9 total*, completed*: int ## counts over the whole list
10 filter*: Filter
11 editing*: int64 ## the item being edited without JavaScript, or 0
12 version*: string
13
14proc h(s: string): string = xmltree.escape(s)
15
16proc filterPath*(f: Filter): string =
17 case f
18 of fAll: "/"
19 of fActive: "/active"
20 of fCompleted: "/completed"
21
22proc checkedIf(b: bool): string = (if b: " checked" else: "")
23
24proc classes(completed, editing: bool): string =
25 if completed and editing: " class=\"completed editing\""
26 elif completed: " class=\"completed\""
27 elif editing: " class=\"editing\""
28 else: ""
29
30include "page.nimf"
31