You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to popular demand for BTR/SSR solutions, as an alternate approach to using the html tagged template literal this issue outlines the use of a declarative syntax template resolver.
The resolver would require an async approach to resolving and attaching the template. This will require a few pieces, the first is the declarative HTML syntax. Once this has been declared on the page for the custom element, it will be added to the element's definition. This template syntax is meant to be able to be interpreted both by JavaScript in the browser, as well as by other languages during BTR/SSR, thus for applying values to create HTML from the template, where JavaScript is not applied we will use JSON and simple data structures.
Below will be an example, as you can see, for browser specific behavior we will keep a JavaScript-like syntax such as with the @click event.
Example HTML:
<f-templatename="my-custom-element"><template><buttondata-fe_click="x.handleClick()" data-fb_disabled="x.disabled">
{{x.greeting}}
</button><inputdata-fp_value="x.value"
><f-whencondition="x.hasFriends"><!--we assume the value passed to the condition is a boolean--><ul><f-repeatitems="x.friends"><!--we assume the items is an array, in this case it might be ["brenda", "james"]--><li>{{x}}</li><!--this now takes the a new context of the individual array item, so this might render as "brenda"--></f-repeat></ul></f-when><f-slotteditems="x.items"><slot></slot></f-slotted></template></f-template>
The reason that all directives are tags is because they should be made optional to allow for lighter bundles. If you don't use <f-when> (for example) you can choose not to include it.
This syntax is a close mirroring of how html template uses directives etc. so as not to confuse current consumers of html tagged template literal. We recognize that there are current efforts to create a standard for declarative HTML, but as they have not passed any meaningful stage at this time we will wait until the platforms proceed with a solution before we consider convergence.
One issue with declarative HTML is that we will not be interpreting any JavaScript, the developers will not be able to do anything like the following: <f-when condition="x.friends.length > 0">. This limitation means that we will only allow a variable that will be assumed to be a boolean.
Anything in the JSON data structure is assumed to be either an @attr or property of the custom element class. Therefore, hasFriends for example could be an observed property or a reflected attribute that is assigned in the constructor.
Declarative HTML Template resolver
The second piece is the interpretation by a resolver to provide the ViewTemplate. This should be located on a different export path, per #7036 compose step example.
HTML Rendering
Fully documented examples with explanations will be provided to ensure processing of a Declarative HTML template is understood and can be resolved. FAST expects certain additions to the HTML for it to be hydratable, that includes comments etc.
Introduction
Due to popular demand for BTR/SSR solutions, as an alternate approach to using the
html
tagged template literal this issue outlines the use of a declarative syntax template resolver.Requires completion of #7036
Requirements
Declarative HTML Template Syntax
The resolver would require an async approach to resolving and attaching the template. This will require a few pieces, the first is the declarative HTML syntax. Once this has been declared on the page for the custom element, it will be added to the element's definition. This template syntax is meant to be able to be interpreted both by JavaScript in the browser, as well as by other languages during BTR/SSR, thus for applying values to create HTML from the template, where JavaScript is not applied we will use JSON and simple data structures.
Below will be an example, as you can see, for browser specific behavior we will keep a JavaScript-like syntax such as with the
@click
event.Example HTML:
The reason that all directives are tags is because they should be made optional to allow for lighter bundles. If you don't use
<f-when>
(for example) you can choose not to include it.html Tagged template version:
Example JSON:
This syntax is a close mirroring of how
html
template uses directives etc. so as not to confuse current consumers ofhtml
tagged template literal. We recognize that there are current efforts to create a standard for declarative HTML, but as they have not passed any meaningful stage at this time we will wait until the platforms proceed with a solution before we consider convergence.One issue with declarative HTML is that we will not be interpreting any JavaScript, the developers will not be able to do anything like the following:
<f-when condition="x.friends.length > 0">
. This limitation means that we will only allow a variable that will be assumed to be a boolean.Anything in the JSON data structure is assumed to be either an
@attr
or property of the custom element class. Therefore,hasFriends
for example could be an observed property or a reflected attribute that is assigned in the constructor.Declarative HTML Template resolver
The second piece is the interpretation by a resolver to provide the
ViewTemplate
. This should be located on a different export path, per #7036 compose step example.HTML Rendering
Fully documented examples with explanations will be provided to ensure processing of a Declarative HTML template is understood and can be resolved. FAST expects certain additions to the HTML for it to be hydratable, that includes comments etc.
Example rendering:
The text was updated successfully, but these errors were encountered: