Skip to content

Commit

Permalink
📖 documentation for named components
Browse files Browse the repository at this point in the history
  • Loading branch information
nanuxbe committed Jul 3, 2024
1 parent 5c079be commit 0b94f2f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/docs/using-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ The inline syntax just uses the plain component name. No `#` or `/`.
<button><svg>...</svg></button>
```

## Named component syntax

Components can also be accessed using their name as a string or variable.

For inline coponents, you may use

```twig
{% inline-component "icon_button" icon="heart" %}
{% inline-component var_containing_component_name %}
```

And similarly for block components

```twig
{% component "icon_button" icon="star" %}
Hello
{% endcomponent %}
{% component var_containing_component_name icon="heart" %}
World
{% endcomponent %}
```

## Component context

Unlike the `include` tag, component template tags **do not** pass the current context to the child component. Variables need to be passed in explicitly.
Expand Down

0 comments on commit 0b94f2f

Please sign in to comment.