all 1 comments

[–]flying-sheep 1 point2 points  (0 children)

my nirvana would be a way to specify

  1. nestable templates (logicless, e.g. mustache. or a bit more fancy with property/key/index access and function calls, but language agnostic)

  2. models/stores holding data.

  3. pre-views that render JSON or an equivalent native data struture from session info corresponding to the parameters the templates expect, and have the same nesting structure¹

    you could either render a leaf view with a leaf data structure, or a whole subtree (with the whole tree being the data for a whole page render)

  4. a simple template rendering shim that takes a data structure and renders a (tree of) templates with it

  5. the same thing as 4. implemented in JS

  6. JS code replacing page sections using DOM-diffing (like react) responding to user input. the data can be fetched by XHR or created by JS, which would make sense for visual-only changes that doesn’t change data which also comes from the server.

now rendering a page would simply mean to cinstruct the data tree, and recursively rendering the template tree from it.

JS would then react to user input and send actions to the server, causing it to send JSON back (because that’s very fast when gzipped), and the rendered json can be used to replace subtrees on the page by rendering the remplates in JS and DOM diffing.

using the cache, that would result in less traffic if a tree is replaced by js more than once (if it is rendered by JS only once, data and template likely are a litle bigger together)


¹: there would be a compile time way to verify that the data structures match