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
In the context of working on #128 , I got to thinking about the kinds of patterns and approaches we can / should support for injecting dynamic data into the page.
Generally, there are two approaches that can be used: Imperative (current pattern)
render(){const{ meta }=this;returnhtml`${meta.map((item)=>{returnhtml`<meta${...item}/> `;})} `;}
Details
There are interesting pros / cons to both approaches. Personally, declarative feels more ergonomic and seems to fit the tagged template literal driven approach of JavaScript
The declarative approach would likely require re-structuring our app-template.js and page-template.js since we would need to do this in the <head> of page. Should probably try and coordinate with changes in Route Based Code Splitting #265
A downside of the imperative approach is that it requires relying on async DOM updates
Imperative is not necessarily idempotent, especially if using DOM methods like appendChild. Order / sequence / duplication becomes a real concern.
In theory, with being able to override xxx-template.js files, user could easily do one instead of the other
This might get us to want to think (possibly) how scripts / styles / etc are passed in via greenwood.config.js. Maybe a just an object like this instead
{head: {scripts: [{src: '',attr: {}}],style: [{href: '',attr: {}}],meta: [{/* same as currently */}]}}
The text was updated successfully, but these errors were encountered:
Type of Change
Summary
In the context of working on #128 , I got to thinking about the kinds of patterns and approaches we can / should support for injecting dynamic data into the page.
Generally, there are two approaches that can be used:
Imperative (current pattern)
Declarative (current pattern)
Details
There are interesting pros / cons to both approaches. Personally, declarative feels more ergonomic and seems to fit the tagged template literal driven approach of JavaScript
<head>
of page. Should probably try and coordinate with changes in Route Based Code Splitting #265appendChild
. Order / sequence / duplication becomes a real concern.The text was updated successfully, but these errors were encountered: