Request.query_dict value syntax

I can’t remember the correct syntax for pulling just the value from request.query_dict.
I have the following code:

{% if request.query_dict.tags is not undefined %}
{% set cat = request.query_dict.tags|split(',') %}
<div class="blog-index__tag-header">
<h4 class="blog-index__tag-heading">Category: {{ cat|replace('-',' ') }}</h4>
</div>
{% else %}

The results are rendered with the brackets and I want to eliminate the brackets.

tmcmillan99_0-1665787286711.png

I appreciate the assistance.
Thanks,

Terry

@tmcmillan99

What |split does is take an input string and turn it into a list and this is why it has the brackets. You could easily just remove |split and it’ll return the same output but without the brackets.

{% set cat = request.query_dict.tags %}

If there’s a particular reason you’re using |split then you’ll need a for loop to loop through the list and output each tag individually.

{% set categories = request.query_dict.tags|split(',') %}
<div class="blog-index__tag-header">
 <h4 class="blog-index__tag-heading">
 Category: 
 {% for cat in categories %}
 {{ cat|replace('-',' ') }}{% unless loop.last %}, {% endunless %}
 {% endfor %}
 </h4>
</div>

@alyssamwilie

Thanks for the correction on the syntax. It’s exactly what I was looking for and gave me some new understanding on Hubl filters.

Terry