0% found this document useful (0 votes)
14 views2 pages

3 4 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

3 4 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Jinja Basics

There are three Jinja delimiters to be aware of in Jinja.

{% … %} is used for statements. These perform any function programming such as


setting a variable or starting a for loop.
{{ … }} is used for expressions. These will print text to the rendered file. In
most cases in dbt, this will compile your Jinja to pure SQL.
{# … #} is used for comments. This allows us to document our code inline. This will
not be rendered in the pure SQL that you create when you run dbt compile or dbt
run.

Dictionaries are data structures composed of key-value pairs.

{% set person = {
‘name’: ‘me’,
‘number’: 3
} %}

{{ person.name }}

me

{{ person[‘number’] }}

Lists are data structures that are ordered and indexed by integers.

{% set self = [‘me’, ‘myself’] %}

{{ self[0] }}

me

If/else statements

{% set temperature = 80.0 %}

On a day like this, I especially like

{% if temperature > 70.0 %}

a refreshing mango sorbet.

{% else %}

A decadent chocolate ice cream.

{% endif %}

On a day like this, I especially like

a refreshing mango sorbet

For loops
{% set flavors = [‘chocolate’, ‘vanilla’, ‘strawberry’] %}

{% for flavor in flavors %}

Today I want {{ flavor }} ice cream!

{% endfor %}

Today I want chocolate ice cream!

Today I want vanilla ice cream!

Today I want strawberry ice cream!

You might also like