Console
FunctionsCanopy

canopy.scripts

The canopy.scripts function outputs the scripts sections of the Canopy Blocks rendered in a block area.

{{ canopy.scripts(handle) }}
ArgumentDescriptionData Type
handleThe block area identifierString

The function collects the {% canopy scripts %} sections of every block template used in the area, so you can load block-specific JavaScript at the end of your page. Each template's scripts section is included once, no matter how many blocks in the area use it.

Use the same handle you pass to canopy.blocks. If the area is rendered with an explicit template list, the scripts sections for those templates are returned.

Example

<body>
  {{ canopy.blocks('main') }}
  {{ canopy.scripts('main') }}
</body>

Last updated on

On this page