在rails应用程序中,therubyracer或libv8是什么? [英] What is therubyracer or libv8 for in a rails application?

查看:121
本文介绍了在rails应用程序中,therubyracer或libv8是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个项目,并且经常在therubyracer和libv8中遇到问题,所以我决定删除它们.似乎唯一将它们用作依赖项的是我想始终删除的较少的rails.

I was working on a project and was having issues with therubyracer and libv8 often, so i decided to remove them. It seemed to be the only thing that used them as a dependency was less-rails which I wanted to remove anyways.

我的主要问题是它们的用途是什么?在普通应用程序中我需要它们吗?如果是,为什么?

My main question is what are they for and do I need them in the average application and if so why?

推荐答案

Rails应用程序可能会在某些方面使用Javascript运行时:

There are a few things for which a Rails app might use a Javascript Runtime:

1)Rails 资产管道需要Javascript运行时才能执行Javascript压缩.

1) The Rails Asset Pipeline requires a Javascript Runtime in order to perform Javascript compression.

2)某些rails ActionView帮助器(例如javascript_include_tag)需要Javascript运行时才能执行Javascript函数.

2) Certain Rails ActionView Helpers like javascript_include_tag require a Javascript Runtime in order to execute Javascript functions.

并不是每个Rails应用程序都使用这些功能,因此,rubyracer gem最初在您的Gemfile中被注释掉的原因;此外请注意,您也可以将NodeJS用作Javascript运行时.

Not every Rails application use those features, hence the reason that therubyracer gem is initially commented out in your Gemfile; Furthermore note that you could alternatively use NodeJS as your Javascript runtime.

有关详细信息,请参见:

For details, see:

http://guides.rubyonrails.org/asset_pipeline.html#javascript-compression

http://www.rubydoc.info/docs/rails/ActionView/Helpers/JavaScriptHelper

http://www.rubydoc.info/docs/rails/ActionView%2FHelpers%2FAssetTagHelper%3Ajavascript_include_tag

正确的路轨"在特定页面上执行javascript的方法

这篇关于在rails应用程序中,therubyracer或libv8是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆