Kaminari generates string instead of html

若如初见. 提交于 2019-12-10 10:54:15

问题


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.

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>

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

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

Thank you in advance for your answers.


回答1:


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?


来源:https://stackoverflow.com/questions/34366509/kaminari-generates-string-instead-of-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!