语法高亮 <script type='text/html'> 中的 javascript 模板元素 [英] Syntax highlight javascript templates within <script type='text/html'> elements

查看:33
本文介绍了语法高亮 <script type='text/html'> 中的 javascript 模板元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Ruby on Rails 模板中,我在 <script type='text/html'> 元素中编写了下划线模板.

In my Ruby on Rails templates I write underscore templates within <script type='text/html'> elements.

我正在使用 rails.vim 和其他插件,但语法高亮和标识规则不适用于这些元素中的 html.

I'm using rails.vim and other plugins, but syntax highlighting and identation rules don't work for the htmls inside these elements.

推荐答案

放在局部.这也使包含所有 html 脚本的页面不会变成怪物.

Put it in a partial. That also keeps the page with all the html scripts from growing into a monster.

<script type="text/x-underscore">
  <%= render 'my_partial_with_syntax_highlighting' %>
</script>

同样使用 text/html 以外的内容作为内容类型.

Ditto for using something other than text/html for content type.

这篇关于语法高亮 &lt;script type='text/html'&gt; 中的 javascript 模板元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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