I have this input:
{%- set value = ['"key"','"value"'] %}
{%- set values = {'"key"':'"value"'} %}
{{ value }}
{{ values }}
and this is the output:
["key", "value"] {"key"="value"}
I have this input:
{%- set value = ['"key"','"value"'] %}
{%- set values = {'"key"':'"value"'} %}
{{ value }}
{{ values }}
and this is the output:
["key", "value"] {"key"="value"}
Sure, this is my Macro:
{%- set macros = true %}
{%- macro demo(param, type) %}
{% set value = ['"key"','"value"'] %}
{% set values = {'"key"':'"value"'} %}
{{ value }}
{{ values }}
{%- endmacro %}
if you notice my second result:
{"key"="value"} _______|
You can notice an equal (=), I don’t think it is supposed to be there, is it?
That is bug number 1, bug number 2 is this one:
This code does not work:
{%- set macros = true %}
{%- macro demo() %}
{% set dict_var = {'name': 'Cool Product', 'price': '$20', 'size':'XL'} %}
{% for key, val in dict_var.items() %}
{{ key }}: {{ val }}<br>
{% endfor %}
{%- endmacro %}
Hope this helps.
In your first issue I’m assuming you’re trying to access the value from the key?
To do this you need to tell the hubl to output that key’s value like so:
{% macro demo(param, type) %}
{% set value = ['"key"','"value"'] %}
{% set values = {'theKey':'the value'} %}
{{ values.theKey }}
{% endmacro %}
{{ demo() }}
EDIT:
Also when defining the key, you do not need quotes. If you must single quotes work.
{% set values = {'theKey':'the value'} %}
or
{% set values = {theKey:'the value'} %}