I want to dynamically set the document.domain in my custom template based on the mode I am in. I use different domains for development and production mode. Currently this is the solution I have:
<script>
{{ if show_details }}
document.domain = 'local.mydomain.com';
{{ else }}
document.domain = 'mydomain.com';
{{ end }}
</script>
This is not perfect since I actually have 3 states: development, staging and production, each with their own domain. The current solution just handles development and production with the help of the show_details flag since this is turned off in production I can use it to set the domain accordingly.
Suggest a solution
I searched existing issues and also had a peak inside the source code but did not find anything the would allow me to set a custom environment variables that are populated inside the template like so:
Is there an existing issue for this?
Describe the problem to be solved
I want to dynamically set the
document.domain
in my custom template based on the mode I am in. I use different domains for development and production mode. Currently this is the solution I have:This is not perfect since I actually have 3 states: development, staging and production, each with their own domain. The current solution just handles development and production with the help of the
show_details
flag since this is turned off in production I can use it to set the domain accordingly.Suggest a solution
I searched existing issues and also had a peak inside the source code but did not find anything the would allow me to set a custom environment variables that are populated inside the template like so:
that would be available inside the html template:
Additional context
If there is a similar existing solution I have missed please let me know.