简体   繁体   English

自定义Rails中的javascript_include_tag输出

[英]Customise javascript_include_tag output in Rails

I'm trying to use a simple rails project to organise and maintain an SVG game. 我正在尝试使用一个简单的Rails项目来组织和维护SVG游戏。 I'd like to use the built in asset pipeline to dynamically include my javascript inside the body of the output SVG file, but I can't work out the best way to get the correct script tag format. 我想使用内置的资产管线动态包括我的输出SVG文件的身体内部的JavaScript,但我不能工作了,以获得正确的脚本标签格式的最佳方式。

I'm using this (application.js is my manifest file): 我正在使用此文件(application.js是我的清单文件):

<%= javascript_include_tag "application" %>

And I'm getting this (as expected): 我得到了这个(如预期的那样):

<script src="/assets/scriptname.js" type="text/javascript"></script>

But I (think I) need this: 但是我(认为我)需要这个:

<script xlink:href="/assets/scriptname.js"></script>

Is there a sensible way to modify or override the tag attributes for javascript_include_tag? 有没有一种明智的方式来修改或覆盖javascript_include_tag的标记属性?

i don't know why u need that, but)) 我不知道为什么你需要那个,但是)

= content_tag("script", "", { "xlink:href" => path_to_asset('scriptname.js') })

or 要么

= javascript_include_tag "", {"type" => nil, "src" => nil, "xlink:href" => path_to_asset('scriptname.js') }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM