{{/* Renders a single Bookshop component, wrapping in in a live editing context tag. Expects a slice: [ , # Component name <_> # Component props ] */}} {{- $component_name := index . 0 -}} {{- $component_props := index . 1 -}} {{- $component_path := partial "_bookshop/helpers/component_key" $component_name -}} {{- $flat_component_path := partial "_bookshop/helpers/flat_component_key" $component_name -}} {{- $resolved_component := false -}} {{- if templates.Exists ( printf "partials/%s" $component_path ) -}} {{- $resolved_component = $component_path -}} {{- else if templates.Exists ( printf "partials/%s" $flat_component_path ) -}} {{- $resolved_component = $flat_component_path -}} {{- end -}} {{- if $resolved_component -}} {{/* Suppress comments when live editing {{ (printf "" $component_name) | safeHTML }} */}} {{- partial $resolved_component $component_props -}} {{/* Suppress comments when live editing {{ "" | safeHTML }} */}} {{- else -}} {{- $file_loc := slicestr $component_path 9 -}} {{- $flat_file_loc := slicestr $flat_component_path 9 -}} {{- partial "_bookshop/errors/err" (printf "Component \"%s\" does not exist.\n Create this component by placing a file in your bookshop at %s or %s" $component_name $file_loc $flat_file_loc) -}} {{- end -}}