Passing variables to templates

I am trying to insert some data inside desk.html

<script>
settings = {
  hash = {{ msg_hash }} 
}
</script>

msg_hash is generated by a function but since jinja doesn’t allows python code inside templates. Which is the best way to pass the variable msg_hash to the template desk.html

call your msg_hash function in desk.py inside get_context() then return msg_hash value:

2 Likes