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 | |
| 4 | import std/xmltree |
| 5 | import store |
| 6 | |
| 7 | type 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 | |
| 14 | proc h(s: string): string = xmltree.escape(s) |
| 15 | |
| 16 | proc filterPath*(f: Filter): string = |
| 17 | case f |
| 18 | of fAll: "/" |
| 19 | of fActive: "/active" |
| 20 | of fCompleted: "/completed" |
| 21 | |
| 22 | proc checkedIf(b: bool): string = (if b: " checked" else: "") |
| 23 | |
| 24 | proc 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 | |
| 30 | include "page.nimf" |
| 31 | |