Solid Template element refactor
A component should be declared as follow:
customElements.define(
"solid-communities",
class extends core.SolidTemplateElement {
description:"blabla"
properties: {
addresses: "addresses",
dataSrc: "data-src",
paginateBy: "paginate-by",
uniq: "uniq",
uploads: "uploads",
}},
routes: [
{name:"list", template:"list.html"},
{name:"map", option: "!this.disableCommunityMapDisplay"},
{name:"community-profile", useId=true},
{name:"community-edit", useId=true},
{name:"community-create", useId=true},
{name:"community-add-member", useId=true}
],
middleware: function(resource) {
resource.count = resource.members.length;
return resource;
}
})
It assumes to have a widget.html
file and a views
directory next to it. The widget.html
file declares widgets using <solid-widget>
.
The directory views
contains templates for the views in html
files. These files are imported and get 3 operations:
- the removal of conditional parts of the html code of the view, depending on properties
- the injection of properties of the component
- the localization of strings
The middleware is a function that is called at the end of the post-processing of the data. It receives the resources as an argument and returns a modified resource.