Support "transparent" HTML templates #437
Labels
good: detailed technical summary
scope: content functions - infrastructure
type: groundworks
Changes are foundational to further issues & code work
These are templates with certain internal "constraints":
content
functions may return one top-level template (not wrapped in any HTML content).And in external behavior, they:
content
just like normal.content
returned a template, slot their own slots into this template before returning it.The content function, like usual, is always called with
slots
. Thegenerate
function (of a content function) is providedslots
(which may carry any values) if the content function is explicitly transparent, i.e. it self-describesslots: 'transparent'
.Typically, transparent templates will only be used as part of infrastructure, for example to acquire context (#434) where internal behavior requires it (#435). Explicit transparency should only be used when the content function is specifically wrapping some template (or multiple templates) with actual content, and so needs to provide those
slots
directly, e.g:Transparent templates never validate any slot values since they're expressly meant not to make assumptions about the contents of the slots. They can introspect on the provided slots, if this is relevant, but acknowledge values are always provided as-is and not filtered or made "nice" (e.g. by providing
html.blank()
instead ofnull
orundefined
on a slot that the internal template specifies istype: 'html'
).Actually making the same expectations about a slot as another template does is a completely separate issue, and generally a much higher-level of abstraction than what transparent templates are working with.
There's some concern about transparent templates that only exist implicitly, i.e. by internal requirement (
'to'
in extra dependencies), because these will look like ordinary templates externally, but will take any slots and then may not provide those slots to another template to be validated. Because we don't statically compute content functions'generate
functions (i.e. the actual layout of the template), there's not really any getting around this right now, but in an ideal world we would...But reaching that ideal is pending on static template layout evaluation.
The text was updated successfully, but these errors were encountered: