allComponents
Description
The
Each entry in
To access a particular template in the
The
allComponents
variable is a default prop loaded by the Plenti generator automatically. It holdsclass constructors for every svelte template on your site. This is allows you to dynamically load any component withouthaving to import it explicitly or worry about SSR issues when generating HTML fallbacks.Understanding Component SignaturesEach 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 becomelayout_components_grid_svelte
. The signatures are absolute, not relative, so they should alwaysstart with "layout" and end with "svelte".Accessing templates in allComponentsTo 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 notationallComponents["layout_components_grid_svelte"]
. It's common to use variables provided from your JSON data sourceto target a particular component, so you'd use bracket notation for that: allComponents[someVariable]
(where "someVariable" is equal toa component signature).