mirror of
https://github.com/github/rails.git
synced 2026-01-28 07:48:00 -05:00
Remove old method of including javascripts define_javascript_functions.
javascript_include_tag and friends do a much better job.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*Edge*
|
||||
|
||||
* Remove define_javascript_functions, javascript_include_tag and friends are far superior. [Michael Koziarski]
|
||||
|
||||
* Deprecate :use_full_path render option. The supplying the option no longer has an effect [Josh Peek]
|
||||
|
||||
* Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik]
|
||||
|
||||
@@ -114,32 +114,6 @@ module ActionView
|
||||
tag(:input, html_options.merge(:type => 'button', :value => name, :onclick => onclick))
|
||||
end
|
||||
|
||||
# Includes the Action Pack JavaScript libraries inside a single <script>
|
||||
# tag. The function first includes prototype.js and then its core extensions,
|
||||
# (determined by filenames starting with "prototype").
|
||||
# Afterwards, any additional scripts will be included in undefined order.
|
||||
#
|
||||
# Note: The recommended approach is to copy the contents of
|
||||
# lib/action_view/helpers/javascripts/ into your application's
|
||||
# public/javascripts/ directory, and use +javascript_include_tag+ to
|
||||
# create remote <script> links.
|
||||
def define_javascript_functions
|
||||
javascript = "<script type=\"#{Mime::JS}\">"
|
||||
|
||||
# load prototype.js and its extensions first
|
||||
prototype_libs = Dir.glob(File.join(JAVASCRIPT_PATH, 'prototype*')).sort.reverse
|
||||
prototype_libs.each do |filename|
|
||||
javascript << "\n" << IO.read(filename)
|
||||
end
|
||||
|
||||
# load other libraries
|
||||
(Dir.glob(File.join(JAVASCRIPT_PATH, '*')) - prototype_libs).each do |filename|
|
||||
javascript << "\n" << IO.read(filename)
|
||||
end
|
||||
javascript << '</script>'
|
||||
end
|
||||
|
||||
|
||||
JS_ESCAPE_MAP = {
|
||||
'\\' => '\\\\',
|
||||
'</' => '<\/',
|
||||
|
||||
@@ -3,14 +3,6 @@ require 'abstract_unit'
|
||||
class JavaScriptHelperTest < ActionView::TestCase
|
||||
tests ActionView::Helpers::JavaScriptHelper
|
||||
|
||||
def test_define_javascript_functions
|
||||
# check if prototype.js is included first
|
||||
assert_not_nil define_javascript_functions.split("\n")[1].match(/Prototype JavaScript framework/)
|
||||
|
||||
# check that scriptaculous.js is not in here, only needed if loaded remotely
|
||||
assert_nil define_javascript_functions.split("\n")[1].match(/var Scriptaculous = \{/)
|
||||
end
|
||||
|
||||
def test_escape_javascript
|
||||
assert_equal '', escape_javascript(nil)
|
||||
assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos'))
|
||||
|
||||
Reference in New Issue
Block a user