HTML1506:意外的令牌,stylesheet_link_tag

HTML1506: Unexpected token, with stylesheet_link_tag

我正在尝试升级一系列 gem,以便获得当前支持。但是,每当我尝试这样做时,我都会在 applications.html.erb 上开始收到 HTML1506。问题发生在 stylesheet_link_tag 和 javascript_include_tag 之间,其中“/body”后跟 "script"。两者都是生成的,所以我似乎无法解决问题。

我正在升级的宝石包括:

Successfully installed sprockets-3.4.0
Successfully installed sprockets-rails-2.3.3
Successfully installed sass-rails-5.0.4
Successfully installed bootstrap-sass-3.3.5.1
Successfully installed jquery-rails-4.0.5

我得到的错误是:

来自更好的错误:

Invalid CSS after "...les.responsive'": expected "{", was ";"

从 F12 控制台:

HTML1506: Unexpected token.

来自 F12 调试器:

</section>
</body>
<script>
(function() {

我知道 after 在语法上是不正确的。但是,我没有生成它们!

applications.html.erb 是:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="author" content="me-at-gmail.com">
  <link href="<%= image_path("item.ico") %>" rel="icon" type="image/png">
  <link rel="apple-touch-icon" sizes="128x128" href="apple-touch-icon.png">
  <title><%= content_for?(:title) ? yield(:title) : "Default title..." %></title>
  <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Key and Car Tracking" %>">
  <%= puts "Action#Controller is " + @_request.filtered_parameters['action'] + "#" + @_request.filtered_parameters['controller'] %>
  <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js", "application", "data-turbolinks-track" => true %>
  <% csrf_meta_tags %>
  <% #render 'layouts/shim' %>
</head>
<body>
<noscript>
  For full functionality of this site it is necessary to enable JavaScript.
  Here are the <a href="http://www.enable-javascript.com/" target="_blank">
  instructions how to enable JavaScript in your web browser</a>.
</noscript>
<header>
  <%= render 'layouts/navigation' %>
</header>
<main role="main">
  <%= render 'layouts/messages' %>
  <div class="container-fluid">
    <div class="row">
        <%= yield %>
    </div>
  </div>
  <h5 style='color: #97b3fc'>Beta Test version.  Not for production. Copyright 2015&copy;</h5>
  <a rel="license" class='hidden' href="http://www.example.com/">Copyrighted 2015</a>
</main>
<%= debug(get_route_pattern) if Rails.env.development? %>
<%= debug(request.class) if Rails.env.development? %>
<%= debug(params) if Rails.env.development? %>
</body>
</html>

Yule 的提示帮助我找到了错误。奇怪的是,我认为样式表是有效的,因为它在升级之前有效。在我注释掉一些代码时,其中有一个错字导致了问题,如下:

/*
@import 'core';
@import 'datepicker';  /* comments */
@import 'theme';       /* comments */
*/

问题在于日期选择器行上注释之后的第一个 */ 终止了顶部 /*。这导致最后的 */ 无效并抛出错误。

这似乎是 SCSS 预处理中的一个明显问题,因为它应该捕获此类错误并提供不那么隐晦的错误消息。不过,无论如何,问题暂时解决了。谢谢尤尔。