简体   繁体   English

Jekyll-液体错误:无法将fixnum转换为String

[英]Jekyll - Liquid error: can't convert fixnum into String

I'm using jekyll with ruby 1.9.1; 我在用jekyll和ruby 1.9.1; my page use the paginator object: 我的页面使用分页器对象:

<li><a href="{{site.paginate_path | replace: ':num', page}}">{{page}}</a></li>

give me the following: 给我以下内容:

<li><a href="Liquid error: can't convert fixnum into String">2</a></li>

But jekyll build doesn't produce any error. 但是jekyll build不会产生任何错误。 When I'm trying trying with ruby 2.1.2, this error isn't happening (but I don't want to update to ruby 2+, unless there is really no other solution) . 当我尝试使用ruby 2.1.2时,不会发生此错误(但我不想更新为ruby 2+,除非确实没有其他解决方案)

I've tryied to add .to_i or .to_s , but I'm not to really understand how it works, and I still get some errors; 我尝试添加.to_i.to_s ,但是我并不是真的很了解它是如何工作的,并且仍然会出现一些错误; I've tried the following: 我尝试了以下方法:

<li><a href="{{site.paginate_path|replace: ':num', page.to_i}}">{{page}}</a></li>
<li><a href="{{site.paginate_path|replace: ':num', page.to_s}}">{{page}}</a></li>

In both cases, I get: 在这两种情况下,我都会得到:

<li><a href="Liquid error: can't convert nil into String">2</a></li>

Is using .to_i or .to_s the way to fix my problem. 正在使用.to_i.to_s解决我的问题的方法。 Why doesn't it work ? 为什么不起作用? Any ideas how I could debug this error ? 有什么想法可以调试此错误吗?

Thanks a lot for your help !! 非常感谢你的帮助 !!

OK, this is misleading. 好,这是误导。 The method is erroneous, but Ruby 2+ has been made to ignore silly mistakes :) Thats a good news. 该方法是错误的,但是已经使Ruby 2+忽略了愚蠢的错误:)那是个好消息。

Simply ask what you want to know, maybe we could help 只需问您想知道什么,也许我们可以帮助您

Looks like the issue you're pointing to got fixed by this commit . 看起来您要解决的问题已通过此commit解决 Hence, using version 2.5.2+ of the liquid gem should solve the issue. 因此,使用2.5.2+版本的液态宝石应该可以解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM