http variables in template

shivammishra
Member

I am trying to use request.headers variable in hubspot page templates but it gives me a white death screen once I try to print it.

At some instances, it does work but most of the time page just crashes when I use this variable in template.

I am confused if its related to cache.

0 Upvotes
7 Replies 7
dennisedson
Community Manager

Hey @shivammishra 

Would you mind dropping your code here so we can see exactly what you are doing? 

@amwilie or @dbeau79 might be able to help 😀

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
shivammishra
Member

Well I am trying to just print headers right now, but I actually want to use one of the headers in if condition to display some blocks from template which is behaving very weird (end up giving the same white screen of death at page) in design manager when I try to use request.headers or request.cookies variables in a if condition inside a template.

 

{{ request.headers }} {% if request.headers['some-header'] %}

{% block header %} {% global_partial path='../partials/header-no-navigation.html' %} {% endblock header %}{% block body %} {% endblock body %}

{% endif %}

dennisedson
Community Manager

@shivammishra 

You should be able to see all available variables in that dict by using the pretty print option

Like this {{ request.headers|pprint }}

You would call the specific variable like this {{ request.headers.cookie }}

Do keep in mind that using request.headers will disable caching on your page

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
shivammishra
Member

well I got that from the documentation but problem is that using {{ request.headers|pprint }} in templates causing pages to crash resulting in white screen of death.

0 Upvotes
dennisedson
Community Manager

@shivammishra , could you point me at the module in question?

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
shivammishra
Member

I am not sure if I understand which module are you referring to as I am using this variable in a template and not in a module.

0 Upvotes
dennisedson
Community Manager

@shivammishra , could you send to me a link to the template.  I don't think the community will be able to help with this one. 

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes