Skip to content

Commit 058dc20

Browse files
Added a use case example for capture tag
1 parent 61848f9 commit 058dc20

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tags/variable.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ Captures the string inside of the opening and closing tags and assigns it to a v
5555
```text
5656
I am being captured.
5757
```
58+
Using `capture`, you can create complex strings using other variables created with `assign`.
59+
60+
<p class="code-label">Input</p>
61+
```text
62+
{% assign favorite_food = 'pizza' %}
63+
{% assign age = 35 %}
64+
65+
{% capture about_me %}
66+
I am {{ age }} and my favorite food is {{ favorite_food }}.
67+
{% endcapture %}
68+
69+
{{ about_me }}
70+
```
71+
72+
<p class="code-label">Output</p>
73+
```text
74+
I am 35 and my favourite food is pizza.
75+
```
5876

5977
## increment
6078

0 commit comments

Comments
 (0)