rubyvoltrb

Using a Volt::Model as a dictionary of Key/Value pairs


I would like to use a Volt::Model as a reactive dictionary in a view.

Ideally, I would like something like this:

<dl>
  {{ dictionary.each do |key, val| }}
  <dt>Term: {{ key }}</dt>
  <dd>Definition: {{ val }}</dd>
  {{ end }}
</dl>

Is this possible in Volt without using an ArrayModel?


Solution

  • Sorry, I don't have .each_pair working in bindings in Volt yet, its on the todo list. Yea, you can use .keys.each do |key| in the mean time.