Rails-在布局中链接样式表和javascript会导致语法错误-“缺少///”; [英] Rails - Linking stylesheet and javascript in layout causes syntax error - "Missing ///"
问题描述
我今天开始工作,发现我的项目由于某种原因引发了语法错误,但是我找不到关于此错误的任何内容。
I came into work today to find that my project is throwing a syntax error for some reason, and I can't find a single thing about this error.
使用 stylesheet_link_tag
或 javascript_include_tag
助手时,我收到 SyntaxError:[stdin]:1:1:缺少///
。
When using the stylesheet_link_tag
or javascript_include_tag
helpers, I receive SyntaxError: [stdin]:1:1: missing ///
.
我注意到的一些事情是:
Some things I have noted are:
- 如果链接未指向有效文件,则可以正常编译。
- 甚至如果文件为空,则仍然会引发错误,因此语法错误肯定在erb中,即使我没有更改
application.html.erb
,因为添加了链接
- If the links dont lead to a valid file, it compiles just fine.
- Even if the files are empty the error is still thrown so the syntax error is definitely in the erb, even though I havent changed my
application.html.erb
since adding the link for the fonts.
编辑:
- 用haml重写布局后,错误仍然存在,因此我怀疑它不是在erb中,而是在用于链接的ruby函数中,尽管我不知道可能发生了什么变化。
- 我刚刚注意到 ExecJs :: RuntimeError,这很有趣,因为我注释掉了javascript链接,因此可以一次处理一个。
任何帮助我表示赞赏。我觉得我在这里想念的东西很简单,但是我一生都找不到。
Any help is appreciated. I feel like I'm missing somethinng very simple here, but i cant find it for the life of me.
如果您想查看我的任何代码,请告诉我,我不确定除此错误页面外还有什么相关内容:
If you want to see any of my code let me know, I wasnt sure what would be relevant other than this error page:
编辑2:
这是我的 appllication.html.erb:
EDIT 2:
Here's my "appllication.html.erb":
<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>{Site Name}</title>
<%= csrf_meta_tags %>
<link href="https://fonts.googleapis.com/css?family=Lato:400,300|Raleway|Tangerine:700" rel="stylesheet">
<%= stylesheet_link_tag "application.css", media: "all", "data-turbolinks-track": "reload" %>
<%#<%= javascript_include_tag "application", 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
推荐答案
此错误是由编译错误引起的。 Rails资产管道。此特定实例是由我从 app / assets / javascripts
中删除了 typescript-rails
后流氓TypeScript文件引起的我的宝石文件。
This error was caused by a compilation error somewhere in the rails asset pipeline. This specific instance was caused by a rogue TypeScript file in app/assets/javascripts
after I had removed typescript-rails
from my Gemfile.
感谢@dstarh我能够找到错误。
Thanks to @dstarh I was able to find the error.
我将离开因为我在任何地方都找不到有关此错误的任何信息。希望它可以帮助其他人。
I'll leave this here since I couldn't find any information on this error anywhere. Hopefully it can help someone else.
这篇关于Rails-在布局中链接样式表和javascript会导致语法错误-“缺少///”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!