formosatek/dotliquid — Issue #54: Working with Dictionary object when key is not KNOWN
Author: smevans521
Created: 2012-02-29 17:14:19+00:00
State: open

I have a basic .NET Dictionary (Dictionary). In my ToLiquid method I do indeed serialize/expose the Dictionary object. My question is how can I ITERATE over the keys in a liquid template just as you would do in regular .NET? It seems as though you MUST know the actual key in order to access the value in the liquid template.

I understand that you could access the value in the liquid template like such

item.dictionary["myKey"]

However I don't know the actual key, so I would prefer to use the "for" construct in DotLiquid to iterate over the keys in order to get the various values. Since the "for" construct works on collections and Dictionary is a collection I thought this could be done somehow but all permutations that I have tried have failed.

Any help would greatly be appreciated.