mustache.js在我的rails应用程序中停留在0.4.0-dev上

时间:2021-08-04 14:27:04

Has anyone ever experienced this? I have vendor'd mustache.js 0.5.1. My vendor'd file is what is served by Rails and what I see in the browser. It's functions are not executed when I call Mustache.to_html (0.4.0 does not have Mustache.render, which is how I discovered this problem). A call to Mustache.version returns '0.4.0-dev'. Something, somewhere, is doing something evil.

有没有人经历过这个?我有供应商mustache.js 0.5.1。我的供应商文件是Rails提供的服务以及我在浏览器中看到的内容。当我调用Mustache.to_html(0.4.0没有Mustache.render,这是我发现这个问题的方法)时,它的功能没有被执行。对Mustache.version的调用返回'0.4.0-dev'。在某个地方,有些东西正在做一些邪恶的事情。

  • vendor/assets/javascripts/mustache.js is 0.5.1.
  • vendor / assets / javascripts / mustache.js是0.5.1。
  • Mustache.version in the Chrome console returns '0.4.0-dev'... so something is overwriting the Mustache prototype. Something evil.
  • Chrome控制台中的Mustache.version返回'0.4.0-dev'...所以有些东西会覆盖Mustache原型。有点邪恶。
  • we've killed code/rubymonk/tmp
  • 我们杀了code / ruby​​monk / tmp
  • we've bounced the asset cache
  • 我们已经退回了资产缓存
  • we've set assets to debug mode
  • 我们将资产设置为调试模式
  • we've switched to production, precompiled the assets, and looked for lingering junk
  • 我们已经转向生产,预编译资产,并寻找挥之不去的垃圾
  • we do not seem to have a 0.4.0 version of mustache loaded in the browser -- but our 0.5.1 code doesn't execute (console.log statements we've added don't run, the actual mustache file is never hit by the debugger)
  • 我们似乎没有在浏览器中加载0.4.0版本的胡子 - 但是我们的0.5.1代码没有执行(我们添加的console.log语句没有运行,实际的胡子文件永远不会被命中由调试器)
  • we've done a full grep of the code/rubymonk directory for 'mustache' and '0.4.0-dev'.... nadda (other than what you'd expect)
  • 我们已经完成了'mustache'和'0.4.0-dev'的代码/ ruby​​monk目录的完整grep .... nadda(除了你期望的)
  • we've looked over the whole hard drive (at least as well as Spotlight does... but it seems to do a pretty good job)
  • 我们已经查看了整个硬盘(至少和Spotlight一样......但它似乎做得非常好)
  • we've grepped the gems directory for both 'mustache' and '0.4.0-dev'... again, nothing.
  • 我们已经为'胡子'和'0.4.0-dev'两个grems了gems目录...再次,没有。

If I'm actually doing something wrong, I'll post the solution once we sort it.

如果我实际上做错了什么,我会在解决后发布解决方案。

-s-

-S-

1 个解决方案

#1


1  

Resolved! Our app is using Intercom (http://intercom.io) -- which is otherwise brilliant -- but it appears the intercom Javascript we download is blowing away Mustache in the global namespace.

解决!我们的应用程序正在使用对讲机(http://intercom.io) - 这是非常出色的 - 但看起来我们下载的对讲机Javascript正在吹掉全局命名空间中的Mustache。

I'll send them a message asking them to namespace their stuff. In the meantime I guess we'll just have to tinker with our own copy of mustache.js to namespace it differently. Which is to say, add the following:

我会给他们发一条消息,要求他们命名他们的东西。与此同时,我想我们只需要修改我们自己的mustache.js副本来命名它。也就是说,添加以下内容:

var MyApp = MyApp || {};

And replace occurances of Mustache with MyApp.Mustache.

并用MyApp.Mustache替换Mustache的出现。

Hopefully this helps someone else. If not, at least I can enjoy sailing ephemeral boats onto the * sea.

希望这有助于其他人。如果没有,至少我可以在*海上享受航行短暂的船只。

-steven

-Steven

PS: We found this out because we were trying to render mustache partials on the client side in pure Javascript, which was apparently broken in mustache 0.4.0 (it would simply spit out our {{ > mypartial }} call directly into the HTML, rendering nothing.

PS:我们发现了这一点,因为我们试图在纯Javascript中在客户端部分渲染胡子部分,这显然在胡子0.4.0中被破坏了(它只会直接将我们的{{> mypartial}}调用吐出到HTML中,什么都没有。

#1


1  

Resolved! Our app is using Intercom (http://intercom.io) -- which is otherwise brilliant -- but it appears the intercom Javascript we download is blowing away Mustache in the global namespace.

解决!我们的应用程序正在使用对讲机(http://intercom.io) - 这是非常出色的 - 但看起来我们下载的对讲机Javascript正在吹掉全局命名空间中的Mustache。

I'll send them a message asking them to namespace their stuff. In the meantime I guess we'll just have to tinker with our own copy of mustache.js to namespace it differently. Which is to say, add the following:

我会给他们发一条消息,要求他们命名他们的东西。与此同时,我想我们只需要修改我们自己的mustache.js副本来命名它。也就是说,添加以下内容:

var MyApp = MyApp || {};

And replace occurances of Mustache with MyApp.Mustache.

并用MyApp.Mustache替换Mustache的出现。

Hopefully this helps someone else. If not, at least I can enjoy sailing ephemeral boats onto the * sea.

希望这有助于其他人。如果没有,至少我可以在*海上享受航行短暂的船只。

-steven

-Steven

PS: We found this out because we were trying to render mustache partials on the client side in pure Javascript, which was apparently broken in mustache 0.4.0 (it would simply spit out our {{ > mypartial }} call directly into the HTML, rendering nothing.

PS:我们发现了这一点,因为我们试图在纯Javascript中在客户端部分渲染胡子部分,这显然在胡子0.4.0中被破坏了(它只会直接将我们的{{> mypartial}}调用吐出到HTML中,什么都没有。