diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-02-07 12:06:35 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-07 12:06:35 -0600 |
commit | e4a7c0bb5b175e6eceb2fe808075d6122521237c (patch) | |
tree | 6f4fab5845fc41a8a7983c4d7faa71cb1b981d69 /actionpack | |
parent | 5f5d2d30a0c02d15b37f8f07db1b0abe9c7309f4 (diff) | |
download | rails-e4a7c0bb5b175e6eceb2fe808075d6122521237c.tar.gz rails-e4a7c0bb5b175e6eceb2fe808075d6122521237c.tar.bz2 rails-e4a7c0bb5b175e6eceb2fe808075d6122521237c.zip |
~ backup files don't clobber original templates [#1818 state:resolved]
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/template.rb | 28 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/hello_world.erb~ | 1 |
2 files changed, 15 insertions, 14 deletions
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index a0ae33caf0..575ec7ce1c 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -236,24 +236,24 @@ module ActionView #:nodoc: format = nil extension = nil - if m = extensions.match(/^([\w-]+)?\.?(\w+)?\.?(\w+)?\.?/) - if valid_locale?(m[1]) && m[2] && valid_extension?(m[3]) # All three - locale = m[1] - format = m[2] - extension = m[3] - elsif m[1] && m[2] && valid_extension?(m[3]) # Multipart formats - format = "#{m[1]}.#{m[2]}" - extension = m[3] - elsif valid_locale?(m[1]) && valid_extension?(m[2]) # locale and extension - locale = m[1] - extension = m[2] - elsif valid_extension?(m[2]) # format and extension + if m = extensions.split(".") + if valid_locale?(m[0]) && m[1] && valid_extension?(m[2]) # All three + locale = m[0] format = m[1] extension = m[2] - elsif valid_extension?(m[1]) # Just extension + elsif m[0] && m[1] && valid_extension?(m[2]) # Multipart formats + format = "#{m[0]}.#{m[1]}" + extension = m[2] + elsif valid_locale?(m[0]) && valid_extension?(m[1]) # locale and extension + locale = m[0] extension = m[1] + elsif valid_extension?(m[1]) # format and extension + format = m[0] + extension = m[1] + elsif valid_extension?(m[0]) # Just extension + extension = m[0] else # No extension - format = m[1] + format = m[0] end end diff --git a/actionpack/test/fixtures/test/hello_world.erb~ b/actionpack/test/fixtures/test/hello_world.erb~ new file mode 100644 index 0000000000..21934a1c95 --- /dev/null +++ b/actionpack/test/fixtures/test/hello_world.erb~ @@ -0,0 +1 @@ +Don't pick me!
\ No newline at end of file |