Kaminari 生成字符串而不是 html [英] Kaminari generates string instead of html

查看:65
本文介绍了Kaminari 生成字符串而不是 html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

11 月份有这样的问题,但没有给出答案.Kaminari 在生产中生成字符串而不是 html并且没有作者的反馈,缺乏声誉并没有让我有机会在那里提问,我的问题也有点不同.我使用 Rails 4.2.4、Kaminari 0.16.3 和 slim 作为我的模板语言.

There was question like this in november, but no anwers was given. Kaminari generates string instead of html in production And no feedback from author, lack of reputation does not give me the opportunity to ask question there, also my problem a little bit different too. I'm using Rails 4.2.4, Kaminari 0.16.3 and slim as my template language.

分页导航生成正确,但是 = paginate @articles 生成的几乎是一个字符串而不是 html.所以它是转义标签并像普通文本一样显示它们(除了第一个 UL 元素)

The pagination navigation is generated correctly, but = paginate @articles generates ALMOST a string instead of html. So it's escape tags and show them like regular text (except first UL element)

<ul class=\"pagination\">&lt;li class=&quot;active&quot;&gt;&lt;a remote=&quot;false&quot;&gt;1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel=&quot;next&quot; href=&quot;/?locale=en&amp;amp;page=2&quot;&gt;2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel=&quot;next&quot; href=&quot;/?locale=en&amp;amp;page=2&quot;&gt;Next › &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;/?locale=en&amp;amp;page=2&quot;&gt;Last &amp;raquo;&lt;/a&gt;&lt;/li&gt;</ul>

它在瘦服务器和 ruby​​ 2.2.2p95(2015-04-13 修订版 50295)上运行.这是第一次发生.

It's running on a thin server and ruby 2.2.2p95 (2015-04-13 revision 50295). This happens the first time.

我接下来尝试:== 分页 @articles原始(分页@文章)htmlentities 宝石电脑图像

I tried next: == paginate @articles raw(paginate @articles) htmlentities gem CGI

预先感谢您的回答.

推荐答案

好的.我发现了问题(但我没有认识到原因,所以......)在你的 _paginator.html.slim 部分?将所有="更改为=="它帮助了我.但我仍然认为这不是一个明智的解决方案.

OK. I found The problem (but i didn't recognise causes, so ...) in your _paginator.html.slim partial? change all '=' to '==' It helped me. But still I think it is not a wise solution.

= paginator.render do
    ul.pagination
        == first_page_tag unless current_page.first?
        == prev_page_tag unless current_page.first?
        - each_page do |page|
          - if page.left_outer? || page.right_outer? || page.inside_window?
            == page_tag page
          - elsif !page.was_truncated?
            == gap_tag
        == next_page_tag unless current_page.last?
        == last_page_tag unless current_page.last?

这篇关于Kaminari 生成字符串而不是 html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆