## HTML rendering. The markup is TodoMVC's own template (shared/reference.html)
## plus the forms and links that make it work without JavaScript.
import std/xmltree
import store
type View* = object
todos*: seq[Todo] ## the items the filter shows
total*, completed*: int ## counts over the whole list
filter*: Filter
editing*: int64 ## the item being edited without JavaScript, or 0
version*: string
proc h(s: string): string = xmltree.escape(s)
proc filterPath*(f: Filter): string =
case f
of fAll: "/"
of fActive: "/active"
of fCompleted: "/completed"
proc checkedIf(b: bool): string = (if b: " checked" else: "")
proc classes(completed, editing: bool): string =
if completed and editing: " class=\"completed editing\""
elif completed: " class=\"completed\""
elif editing: " class=\"editing\""
else: ""
include "page.nimf"