Name: template-instantiation
Owner: PolymerLabs
Description: null
Created: 2018-01-05 22:36:32.0
Updated: 2018-03-24 16:30:06.0
Pushed: 2018-03-18 04:50:31.0
Homepage: null
Size: 105
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Template Instantiation is a new web platform feature with ongoing, developing proposals coming out of a few corners of the ecosystem.
The most developed proposal so far comes from Ryosuke Niwa at Apple and can be found here.
This change proposes a Template Instantiation prollyfill implementation based on Ryosuke Niwa's proposal, and adapted with idioms and features found in the Polymer Team's own lit-html.
Template Instantiation is meant to offer a standard API for enabling some level of dynamism in otherwise static HTML templates. There are several relevant use cases outlined in the Apple proposal.
Conceptually, this implementation consists of many of the same constructs. However, there are a few notable differences.
Compared to the Apple proposal, the implementation here is lacking:
InnerTemplatePart
.replace
or replaceHTML
on NodeTemplatePart
.~Areas where this implementation diverges from Apple's proposal include:
TemplatePart
is updated by value, which has special meaning depending on
the implementation of the derived TemplatePart
derivative in question
(a la lit-html).Features included in this implementation that are not covered by Apple's proposal:
TemplateAssembly
)TemplateAssembly
as a value type that may be assigned
to a TemplateNodePart
.~TemplatePart
creation via TemplateProcessor
's
partCalback
(a la lit-html)~TemplateProcessor
, with the expectation that
in v0 an author will be expected to provide their own.NodeTemplateRule
and AttributeTemplateRule
.HTMLTemplateElement
and held by a
TemplateDefinition
TemplateInstance
.TemplateRule
, where it can access the
related rule.Text
node somewhere.TemplateInstance
(not sure why yet)TemplateRule
instances with a related DocumentFragment
and held by a
TemplateInstance
.HTMLTemplateElement
(for cacheability, cache can be overridden
if desired).TemplateRule
spotsTemplateInstance
.lit-html
's TemplateResult
.TemplateDefinition
instance.TemplateInstance
generated
from the TemplateDefinition
.NodeTemplatePart
, enabling
TemplateInstance
nesting.TemplatePart
creation via partCallback
(working name
borrowed from lit-html).~TemplatePart
updating via processCallback
(working name
borrowed from Apple's proposal).TemplateDefinition#createInstance(processor, state?)
(not
to be invoked directly by author at this time).TemplateProcessor
TemplatePart
instances, generated by cross-referencing the
TemplateDefinition
's TemplateRules
against its own content and
invoking the TemplateProcessor
's partCallback
method.TemplateProcessor
, which is otherwise stateless)TemplateInstance#update(newState)
TemplateAssembly
as a state valueHTMLTemplateElement#createInstance(processor, state?)
creates
a TemplateDefinition
for the HTMLTemplateElement
if one does not exist,
then invokes TemplateDefinition#createInstance(processor, state?)
and
returns that value.