r:var
<r:var />
A tag for a variable. A variable is a place or tag that can hold different values at different times.
It is a container for a value.
Attribute Options
name="something_to_call_it"
- String, required.
This attribute is the name of the variable.
Example:
<r:var name="my_variable_name" />
NOTE: Variable names should use underscores or camelCase. Do not use dashes as CleanSlate can interpret these as "minus" logic.
This tag is closely related to r:set_var
.
See an example of r:var
in Brand Pattern's
main navigation file.
{{ var }}
A variable is a container for a value. It is a tag that can hold different values at different times.
The official Liquid documentation has a page dedicated to variables.
Filter options
See the docs on r:set_var
and the official Liquid documentation to see available filters.
Examples
NOTE: Variable names should use underscores or camelCase. Do not use dashes as CleanSlate can interpret these as "minus" logic.
First, a variable must be created using assign
or capture
.
{% assign bear = "Smokey" %}
Then you can use your variable with either object or tag notation. Here's how to use it with object notation:
<h2>Hi, {{ bear }}!</h2>
<!-- Output: <h2>Hi, Smokey!<h2> -->
Here's how it would be used with tag notation:
{% if bear == "Smokey" %}
Hello, {{ bear }}!
{% endif %}
<!-- Output: "Hello, Smokey!" -->
You can also combine variables with filters:
{{ bear | upcase }}
<!-- Output: "SMOKEY" -->
Last updated on March 16, 2021.
We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:
- A brief description of the issue
- A link to the page where you saw the issue
- Screenshots that illustrate the problem - How do I take a screenshot?
Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.