简体   繁体   English

是否有任何努力将一些Rails的View Helpers移植到Javascript?

[英]Have there been any efforts to port some of Rails' View Helpers to Javascript?

It would be great to have helpers like linkTo() , truncate() , and pluralize() in Javascript. 在Javascript中拥有诸如linkTo()truncate()pluralize()类的助手将是很棒的。 Have there been any efforts to port some or all of Rails' view helpers to Javascript? 是否有任何努力将Rails的部分或全部视图助手移植到Javascript?

If you just need one or two, you can find snippets for pluralize and singularize or another for truncating . 如果只需要一个或两个,则可以找到用于复数和单数化的代码片段,用于截断的另一个代码 片段

And actually, there's now a javascript library that handles a lot of the syntactic sugar: 实际上,现在有了一个处理许多语法糖的javascript库:

Sugar.js Sugar.js

Like I said in my original post, no need to include a whole library if you only want one or two of them or can manage to just use the Rails helpers, but the option to have them is out there. 就像我在原始帖子中所说的那样,如果您只需要其中一个或两个,或者可以仅使用Rails助手,则无需包括整个库,但是可以选择使用它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在JavaScript模板中使用Rails的视图助手 - Using Rails' view helpers inside javascript templates jQuery是否具有将客户端滚动到视图端口底部的任何功能? - Does jQuery have any functions to scroll the client to the bottom of the view port? 我在使用javascript qutation时遇到了一些麻烦 - i have been facing some trouble with the javascript qutation 有没有其他方法可以访问已被隐藏或重新定义的 JavaScript 全局变量? - Is there any alternative way to access JavaScript globals that have been shadowed or redefined? 编辑任何表单字段时显示的Javascript Box - Javascript Box to appear when any form fields have been edited 有没有办法在Rails 4的Coffeescript / Javascript中使用ActionView Helpers? - Is there a way to use ActionView Helpers in Coffeescript/Javascript in Rails 4? 有没有办法在页面加载时自动运行一些javascript(例如Bookmarklet)? - Is there any way to have some javascript (such as a Bookmarklet) autorun on page load? 直接从Rails视图发送JavaScript是否有问题? - Any Problems with sending javascript directly from rails view? 在所有ASP.NET启动脚本执行完毕后,如何执行某些Javascript? - How can I execute some Javascript after all ASP.NET startup scripts have been executed? 如果在javascript中点击任何一个按钮,如何为多个按钮执行相同的功能 - how to do a same function for multiple button if any of them have been clicked in javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM