Jekyll: make a new hash

I’m using

I wanted to create a new hash object, and constructs like these don’t work:

{% assign h = { "foo" => 6, "bar" => 7 } %}
{% assign h["foo"] = 6 %}

This does work though. In _includes/mkhash.inc just

{% assign h = include %}

and in the requesting page,

{% assign arr = '' | split: '.' %}

{% include mkhash.inc foo = 6 bar = 7 %}
{% assign arr = arr | push: h %}

{% include mkhash.inc whiz = 8 bang = 9 %}
{% assign arr = arr | push: h %}

{{ arr | jsonify }}

producing

[{"foo":6,"bar":7},{"whiz":8,"bang":9}]

Posts