This project is archived and is in readonly mode.
![Lawrence Pit Lawrence Pit](https://entp-lh-avatar-production.s3.amazonaws.com/avatars/20836/large.png?AWSAccessKeyId=AKIAJ4QBZRZBVMOUBNZA&Expires=2014353500&Signature=yHdOAOAFjQJWhe5B25iiZf3Vogs%3D)
Ruby 1.9 style String interpolation support for lower ruby versions.
Reported by Lawrence Pit | July 6th, 2009 @ 01:34 AM | in 2.x
Attached patch adds ruby 1.9 style String interpolation support for lower ruby versions. Thanks to code from Masao Mutoh's GetText gem.
The reason for including this patch is that for I18n we'd like to switch from "{{arg}}" style named arguments to standard ruby 1.9 syntax, i.e. : "%{arg}". This makes later upgrades to ruby 1.9 easier and it makes string interpolation a lot more powerful/flexible than what is currently possible.
Comments and changes to this ticket
-
Lawrence Pit July 6th, 2009 @ 01:35 AM
- no changes were found...
-
Sven Fuchs July 6th, 2009 @ 11:38 AM
- Assigned user set to Jeremy Kemper
+1 this would make our upgrade path to ruby 1.9 much smoother AND add a ton of flexibility to our interpolation api
Jeremy, wdyt? :)
-
Repository July 8th, 2009 @ 12:22 AM
- State changed from new to resolved
(from [da635394c1c3004f4dacf4a35275404e5b1aef43]) Ruby 1.9 style String interpolation support for lower ruby versions. Thanks to code from Masao Mutoh's GetText gem. [#2870 state:resolved]
Signed-off-by: Yehuda Katz wycats@yehuda-katzs-macbookpro41.local
http://github.com/rails/rails/commit/da635394c1c3004f4dacf4a3527540... -
Sven Fuchs July 8th, 2009 @ 05:26 PM
- State changed from resolved to open
- Tag changed from 3.0, patch to 2-3-stable, 3.0, patch
- Assigned user changed from Jeremy Kemper to Yehuda Katz (wycats)
Thanks for applying, Yehuda :)
Couple of things:
I noticed the tests don't pass on Ruby 1.9 because Masao's code does not mirror Ruby 1.9's behaviour exactly, but the tests of course specify what the code does. This is true for two situations where Ruby 1.9 raises exceptions while Masao's extension doesn't:
- Ruby 1.9 raises a KeyError exception for missing named interpolation args (e.g. "%{foo}" % {:bar => :bar})
- Ruby 1.9 raises an ArgumentError when mixing named and unnamed placeholders (e.g. "%{foo} %f" % [1.0])
Also, we'll only want to include this code when we're on < Ruby 1.9.
I'll append a patch that fixes these things and also improves the docs and Rails conventions compliance a little bit.
After applying this, can you please also BACKPORT this to 2.3-stable? That'd be great :)
I'll reopen the ticket and assign to Yehuda.
-
Repository July 18th, 2009 @ 09:11 PM
- State changed from open to committed
(from [17d5cc12b9f8d0d78a081d231e7e0c5ec9df1104]) * don't include String#% for Ruby 1.9 * raise a KeyError exception for missing named interpolation args (like Ruby 1.9 does) * raise an ArgumentError when mixing named and unnamed placeholders (like Ruby 1.9 does) * improve docs and comply a bit more w/ Rails names/conventions
[#2870 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/17d5cc12b9f8d0d78a081d231e7e0c... -
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
-
2870 Ruby 1.9 style String interpolation support for lower ruby versions. (from [da635394c1c3004f4dacf4a35275404e5b1aef43]) Ruby 1....
-
2870 Ruby 1.9 style String interpolation support for lower ruby versions. [#2870 state:committed]