[英].js.erb file won't precompile
當我嘗試運行rake assets precompile
以下錯誤: Unexpected token: operator (>)
。 我發現這是由於index.js.erb所致,因為將文件名更改為.html.erb使其可以編譯。 這是index.js.erb的內容:
$('#haikus').append('<%= j render(@haikus) %>');
<% if @haikus.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@haikus) %>');
<% else %>
$('.pagination').remove();
<% end %>
haikus.js.coffee:
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 200
$('.pagination').html('Loading...')
$.getScript(url)
$(window).scroll()
index.html.erb:
<div id="haikus">
<%= render @haikus %>
</div>
<div class="row pagination">
<div class="large-12 columns">
<%= will_paginate @haikus %>
</div>
</div>
我該如何修復並使其編譯?
謝謝!
我懷疑這與它有很多關系:
將文件名更改為.html.erb使其可以編譯
您是否嘗試過從js.erb文件中刪除邏輯? 我真的在想無法從javascript文件調用“ will_paginate
”的東西。 也許您只需要在文件中包含這一行並查看其是否可以編譯?
$('#haikus').append('<%= j render(@haikus) %>');
如果那不起作用,那么我們知道這與之有關; 否則,最有可能與will_paginate有關
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.