Skip to content

Instantly share code, notes, and snippets.

@elliot42
Last active May 21, 2016 23:53
Show Gist options
  • Save elliot42/bd31b8273fdfbc775f6a529a8e3d4b10 to your computer and use it in GitHub Desktop.
Save elliot42/bd31b8273fdfbc775f6a529a8e3d4b10 to your computer and use it in GitHub Desktop.

back to unrelated thing about static typing and HTML template rendering

I think the thing that makes it back into sort of

a tractable problem (especially in static typed land)

is not thinking of it as a string interpolation problem :: String -> String

but as a tree rendering problem :: DOMTree -> String

and decomplects a bunch of BS (edited)

because instead of putting logic in your templates

which seems like an extraordinarily complex thing

first you just need a DOMTree value

and you can do whatever gymnastics logic :: a -> DOMTree

then the renderer is just :: DOMTree -> String

And like, regular programming languages and data structure literals are Good Enough

at constructing trees, that’s why Hiccup/Sablono can use normal map etc.

normal data structure functions to construct normal trees

i.e. most of the ​_content logic_​ is at the data-structure tree-structure level (edited)

and then the ​_string rendering_​ is just a mechanical transform of the tree that’s been constructed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment