How To Access hx_object In Template
To access the hx_object in a template, use it as you would any other context variable:
it will be available in the template as hx_object.
If you want to rename it to have it accessible as something else, override the hx_object_name attribute in your HxRequest class.
from hx_requests.hx_requests import BaseHxRequest
class MyHxRequest(BaseHxRequest):
hx_object_name = "my_object" # in the template: {{ my_object }}
The hx object is the object passed into tmeplate tag
<button {% hx_get 'my_hx_request' object=my_instance %}></button> <button {% hx_post 'my_hx_request' object=my_instance %}></button>
Kwargs
Any kwargs passed to the hx_get or hx_post template tag will be available in the template as context variables by default.
<button {% hx_get 'my_hx_request' my_kwarg="my_value" %}></button>
In the template, you can access the kwarg as you would any other context variable:
<p>{{ my_kwarg }}</p>
If you want to prevent possible collisions between kwargs and existing context variables,
set kwargs_as_context = False in your HxRequest.
This will make the kwargs available as a dictionary called kwargs in the template.
from hx_requests.hx_requests import BaseHxRequest
class MyHxRequest(BaseHxRequest):
kwargs_as_context = False # in the template: {{ kwargs.my_kwarg }}