DotLiquid运行时错误液体错误:无法将“System.Int32”类型的对象强制转换为“System.String”类型

时间:2014-01-21 05:31:54

标签: hash casting key liquid

我刚学习DotLiquid,但发现使用哈希

的问题

选项是哈希

        Hash h = new Hash();
        h.Add("Value", this.Field.Value);
        h.Add("Label", this.Field.Label);
        h.Add("FieldName", this.Field.FieldName);

        Hash Options = new Hash();
        Options.Add("4", "Option 1");
        Options.Add("5", "Option 2");
        Options.Add("99", "Option 3");
        h.Add("Options", Options);

在我的模板中

 {% for item in Options -%}
    {{ item[0] }}{{ item[1] }}
 {% endfor -%}

上面的代码来自引用FOR循环的https://github.com/Shopify/liquid/wiki/Liquid-for-Designers页面

  

迭代哈希时,item [0]包含键,item [1]包含值:

{% for item in hash %}
  {{ item[0] }}: {{ item[1] }}
{% endfor %}

但是当它被渲染时会生成

液体错误:无法将“System.Int32”类型的对象强制转换为“System.String”.Liquid错误

不确定是什么问题?

0 个答案:

没有答案
相关问题