'Pass variable to jinja template
I am quite new with Python and jinja and I would need some help about the following problem.
In order to deal with some variable in airflow, I need to define a template which involves a variable my_variable inserted by the user. I would need the (integer) value of such variable to be inserted into my template. More precisely, the idea is the following: first, I ask the user to insert a variable
my_variable=input('insert the variable:')
next, in the case when, for example, the user choose to set my_variable=2, I would like to be able to have a template in the form
my_template="{{My variable is 2}}".
Thank you in advance, I hope I managed to explain myself.
Solution 1:[1]
As per comment the ask is to acquire a variable defined in the Variable environment of the airflow UI in such case variables can be references in templated fields using {{ var.value.my_variable }} or {{ var.json.my_variable }} as per documentation.
Solution 2:[2]
When you run the next app, the variables in .evn will only load to next app if they start with NEXT_PUBLIC_, remember you are not running the next app from cmd, your starting point is 'npm start' in docker which only loads env variable with names stating from "NEXT_PUBLIC"
NEXT_PUBLIC_ANALYTICS_ID=abcdefghijk
More info here - https://nextjs.org/docs/basic-features/environment-variables
Just prefix all your variables with "NEXT_PUBLIC"
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=my-public-key...
NEXT_PUBLIC_RECAPTCHA_SECRET_KEY=my-secret-key...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tomasz Urbaszek |
| Solution 2 | Santosh Karanam |
