Tonysres
Tonysres

Reputation: 79

YAML Plain value cannot start with directive indicator character %

I'm trying to create a list in YAML that is parsed by jinja to be used in a for loop. I have the following line:

{%- set my_var = [1, 2, 3, 4, 5, 6, 7] %}

And VSCode gives me the following error: "Plain value cannot start with directive indicator character %"

However when I have something like this:

{%- set my_var1 = [
   ('str1', '100'),
   ('str2', '200'),
   ('str3', '300')
] %}

I dont get any errors or warnings, I've tried searching for the error and can't seem to find any information, what is causing this error? Thank you for any help!

Upvotes: 0

Views: 3578

Answers (1)

flyx
flyx

Reputation: 39688

Make sure you selected Jinja for the syntax in VSCode and not YAML.

Processing this input as YAML without Jinja preprocessing is obviously a syntax error since it is not valid YAML.

Upvotes: 2

Related Questions