markjgsmith

Server-side components

2024-05-29 10:36:00 +07:00 by Mark Smith

This post is part of the My static generator series. Follow the link to read the overview and get a complete list of posts.

Server-side components are a primitive that you can use directly in your render templates. They contain their own template but crucially they also have functionality associated with them in the form of functions. The component's template can use the functions to perform various transformations on the text of your templates and data passed to them at rendertime.

The ability to keep functionality and form together like this is very beneficial when it comes to conceptualising the various pieces of the page you are trying to render. You can be sure that at rendertime the template will have available to it both the data and functionality it needs to render the templates.

It also makes it possible to easily reuse pieces of pages in multiple places. What's more server-side components can be packaged up into plugins, which makes it easy to share things you build with others.

The core of server-side components is all just regular javascript, no complicated libraries. However you can if course use libraries inside your components.

For enquiries about my consulting, development, training and writing services, aswell as sponsorship opportunities contact me directly via email. More details about me here.