TextMate js.erb:切换 <%= %>、<% %>;
我正在使用 js.erb 模板来渲染一些 jQuery。在 TextMate 中编辑 html.erb 文件时,我经常使用方便的组合键 ctrl+> 来创建并切换以下标签:
<%= %>
<% %>
<%- -%>
<%# %>
编辑 js 时此快捷键默认不起作用.erb 文件。在捆绑编辑器中,我找到了一个名为“Insert ERb's <% .. %> or <%= .. %>”的代码片段在“红宝石”下。通过将“source.js”添加到范围选择器,我能够使插入工作,但是当我多次按下组合键时,我没有切换标签,而是在标签内得到了一个标签,如下所示:
<%= <%= %> %>
我尝试过更改名为“Toggle ERb Tags”的命令的范围,但我似乎无法切换工作。有什么建议吗?
2010 年 11 月 19 日更新:
在本周发布的 Textmate 新版本:1.5.10 (1623) 中,这不再是问题。
I'm using a js.erb template to render some jQuery. When editing an html.erb file in TextMate, I frequently use the convenient key combo, ctrl+>, to create and then toggle the following tags:
<%= %>
<% %>
<%- -%>
<%# %>
This shortcut doesn't work by default when editing js.erb files. In the Bundle Editor, I found a snippet called "Insert ERb’s <% .. %> or <%= .. %>" under "Ruby". By adding "source.js" to the scope selector I was able to get insertion to work, but when I pressed the key combo multiple times, instead of toggling the tag I got a tag inside of a tag like this:
<%= <%= %> %>
I've tried changing the scope of the command called "Toggle ERb Tags" but I can't seem to get toggling to work. Any suggestions?
Update November 19, 2010:
This is no longer a problem in the new version of Textmate that came out this week: 1.5.10 (1623).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
出现这种情况的一个可能原因是为您生成尖括号的代码片段是这样定义的:
这会在发生制表符触发后将此文本放入您的源代码中。
$0
是光标的占位符;这是片段完成后最后的安息之地。由于光标位于中间并且这是一个简单的片段,因此重复执行制表符触发将嵌套这些括号。为了实现你想要的,你必须在脚本中完成。您可以使用任何脚本语言,只要适当地指定 shebang 行即可。我不是一个熟练的脚本编写者,所以我将尝试使用伪代码来解决这个问题。
虽然不多,但我希望这会有所帮助
One possible reasono why this is the case is that the snippet that generates the angle brackets for you is defined thus:
This puts this text into your source after the tab-trigger occurs. The
$0
is a placeholder for the cursor; it's final resting place after the snippet is completed. Since the cursor rests in the middle and this is a simple snippet, repeatedly performing the tab-trigger will nest these brackets.To achieve what you want, you have to do it in a script. You can use any scripting language as long as you appropriately specify the shebang line. I am not a proficient scripter so I'll try to solve this using pseudocode.
It's not much but I hope this helps
Textmate 更新 1.5.10 (1623) 已修复此问题。
This was fixed with Textmate update 1.5.10 (1623).
我刚刚也遇到了这个问题,即使更新了 TextMate 和捆绑包。我通过将
source.js.rails
添加到代码片段“Insert ERb's <% .. %> or <%= .. %>”的范围选择器来修复此问题。确保您没有更改类似命令“Toggle ERb Tags”的范围选择器。这将正确插入 ERb 标签并按预期切换它们。I just ran into this problem too, even with updated TextMate and bundles. I fixed it by adding
source.js.rails
to the scope selector of the snippet "Insert ERb’s <% .. %> or <%= .. %>". Make sure you don't change the scope selector for the similar command "Toggle ERb Tags". This inserts the ERb tags correctly and also toggles them as expected.由于 Ruby 1.9 中的更改,您的 Ruby on Rails Textmate 包可能已过时。
更新您的 tmbundle,这个问题就会消失。
Your Ruby on Rails Textmate bundle may be outdated due to changes in Ruby 1.9.
Update your tmbundle and this problem should go away.