allComponents

Description

The allComponents variable is a default prop loaded by the Plenti generator automatically. It holds class constructors for every svelte template on your site. This is allows you to dynamically load any component without having to import it explicitly or worry about SSR issues when generating HTML fallbacks. 

Understanding Component Signatures

Each entry in allComponents is saved as a "component signature" to ensure uniqueness. The component signature for a template is simply its path with any forward slashes "/" or periods "." converted into underscores "_". For example layout/components/grid.svelte would become layout_components_grid_svelte. The signatures are absolute, not relative, so they should always start with "layout" and end with "svelte". 

Accessing templates in allComponents

To access a particular template in the allComponents object, use the component signature with either dot notation (e.g. allComponents.layout_components_grid_svelte or bracket notation allComponents["layout_components_grid_svelte"]. It's common to use variables provided from your JSON data source to target a particular component, so you'd use bracket notation for that: allComponents[someVariable] (where "someVariable" is equal to a component signature).