Passing variables to templates

I am trying to insert some data inside desk.html

settings = {
  hash = {{ msg_hash }} 

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 inside get_context() then return msg_hash value: