Hash DotLiquid运行时错误Liquid错误:无法强制转换类型为';System.Int32';输入';System.String';
我只是在学习dotluid,但在使用散列时发现了一个问题 选项是散列Hash DotLiquid运行时错误Liquid错误:无法强制转换类型为';System.Int32';输入';System.String';,hash,casting,key,liquid,Hash,Casting,Key,Liquid,我只是在学习dotluid,但在使用散列时发现了一个问题 选项是散列 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.
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循环的页面
迭代哈希时,项[0]包含键,项[1]包含值:
但渲染时会生成
液体错误:无法将“System.Int32”类型的对象强制转换为“System.String”类型。液体错误
不确定问题出在哪里?我决定使用HASH标记并使用DROP类,这样更简单。HeyChris,你有没有可能分享一段代码。我遇到了同样的问题。谢谢!看起来这是一个已知的bug(在您发布问题后被发现):
{% for item in hash %}
{{ item[0] }}: {{ item[1] }}
{% endfor %}