Is it possible to infer the environment name within the template?
iancullinane opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
I have two environments, local and production. Production has a proper url (eg www.product.com
and in local production it is a vm so the address would be 172.18.1.100
and it may have a port. I would like to be able to switch production and dev with these addresses.
Describe the solution you'd like
I wanted to use some kind of if
in scriban that can lookup which environment I am in and set a user variable accordingly.
Describe alternatives you've considered
I tried looking around for was default variables are available but couldn't find them. Nor did I see some place to print them. Are there default variables that can be accessed? I also don't see a way to print things that may be relevant in scripting, but I admit my xp is low with the languages and tooling.
No, currently not. But you could simply put the environment name into the environment data like so:
{
"name": "Production"
}
This would be available as {{ env.name }}
in Scriban. Please note that we currently do not provide a way to access environment data in Scripting (=Tests), but this is on our roadmap.
This has been implemented and was released with the newest beta release. It will be included in the next stable version.
Kreya 1.14 has been released