Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paginate() shows raw HTML with Slim template engine #73

Closed
mrcasals opened this issue Apr 1, 2011 · 7 comments
Closed

paginate() shows raw HTML with Slim template engine #73

mrcasals opened this issue Apr 1, 2011 · 7 comments
Assignees

Comments

@mrcasals
Copy link

mrcasals commented Apr 1, 2011

Well, I'm using Slim as my template engine, and whenever I put "=paginate(@videos)" it shows raw HTML instead of the actual links. I got it working with "=paginate(@videos).to_s.html_safe", but I think this shouldn't be the way kaminari should work...

Thanks anyway for your work!

@yuki24
Copy link
Member

yuki24 commented Jul 27, 2011

Actually kaminari uses raw method in some files.

$ grep -r raw .
./app/views/kaminari/_first_page.html.erb:  <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
./app/views/kaminari/_first_page.html.haml:  = link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote
./app/views/kaminari/_first_page.html.slim:  == link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote
./app/views/kaminari/_gap.html.erb:<span class="page gap"><%= raw(t 'views.pagination.truncate') %></span>
./app/views/kaminari/_gap.html.haml:  = raw(t 'views.pagination.truncate')
./app/views/kaminari/_gap.html.slim:  == raw(t 'views.pagination.truncate')
./app/views/kaminari/_last_page.html.erb:  <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
./app/views/kaminari/_last_page.html.haml:  = link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote}
./app/views/kaminari/_last_page.html.slim:  == link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote}
./app/views/kaminari/_next_page.html.erb:  <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
./app/views/kaminari/_next_page.html.haml:  = link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
./app/views/kaminari/_next_page.html.slim:  == link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
./app/views/kaminari/_prev_page.html.erb:  <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
./app/views/kaminari/_prev_page.html.haml:  = link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote
./app/views/kaminari/_prev_page.html.slim:  == link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote
./spec/fake_app.rb:app.routes.draw do

I think it's much better and safer to replace #raw with #html_safe. I'm not sure if it solves your problem, but I will just work on it and send a pull request soon.

@kapso
Copy link

kapso commented Apr 4, 2012

I am running into the same issue when using slim template. I tried to_s.html_safe but that did not fix the issue for me. Has this been fixed? I am using kaminari (0.13.0) with rails 3.2.3.

@derencius
Copy link

@ghost ghost assigned yuki24 Jul 1, 2013
@zzak
Copy link
Contributor

zzak commented Jul 1, 2013

@yuki24 any update on that PR? 😈

@zzak
Copy link
Contributor

zzak commented Jul 12, 2013

@yuki24 I sent a PR for to use html_safe instead, mostly just for Travis CI.

If I don't hear any objections in a few days I will merge it.

@yuki24
Copy link
Member

yuki24 commented Jul 16, 2013

I'm closing this issue in favor of #418.

@nickrivadeneira
Copy link

For future reference, the sample @derencius linked to is now located here.

Reproduced here, just in case it gets moved or deleted:

= 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?

kimiya310 added a commit to startup-technology/start-dash that referenced this issue May 6, 2018
paginate() shows raw HTML with Slim template engine
kaminari/kaminari#73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants