{{ cms_code(name, { value: '...', class: '...' }) }}
ArgumentDescriptionData Type
nameThe element identifierString
value (optional)The code to be displayedString
class (optional)A space-separated list of CSS classes to style the code componentString

The class variable is only accessible in the code. All other variables are available in the Canopy editor.

Code component template

<code class={{ class }}>
  <pre>{{ value }}</pre>
</code>

Rendered HTML output

<code class="text-sm">
  <pre>
  function greet() {
      console.log("Hello, World!");
  }
  greet();
  </pre>
</code>

Example

 {{ cms_code('mycode', { value: 'function greet() {\n    console.log("Hello, World!");\n}\ngreet();', class: 'text-sm' }) }}

Was this helpful?

Copyright © 2024 Blutui.