Syntax highlight javascript templates within <script type='text/html'> elements

可紊 提交于 2019-12-08 11:09:19

问题


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

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


回答1:


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>

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



来源:https://stackoverflow.com/questions/17157519/syntax-highlight-javascript-templates-within-script-type-text-html-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!