aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_overview.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-08-23 14:09:16 +0200
committerXavier Noria <fxn@hashref.com>2009-08-23 14:09:46 +0200
commit8458abb5e52dc38daa8176ed39d9dc45aa98f261 (patch)
tree839664f62e3ece9a2d2d13ab291ddf212c3a0c0c /railties/guides/source/active_support_overview.textile
parent4d0df0a4e26b62886b848babbac074daeda41fe0 (diff)
downloadrails-8458abb5e52dc38daa8176ed39d9dc45aa98f261.tar.gz
rails-8458abb5e52dc38daa8176ed39d9dc45aa98f261.tar.bz2
rails-8458abb5e52dc38daa8176ed39d9dc45aa98f261.zip
AS guide: documents key-based interpolation
Diffstat (limited to 'railties/guides/source/active_support_overview.textile')
-rw-r--r--railties/guides/source/active_support_overview.textile13
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_overview.textile b/railties/guides/source/active_support_overview.textile
index 5e6c2030c6..06d750afc9 100644
--- a/railties/guides/source/active_support_overview.textile
+++ b/railties/guides/source/active_support_overview.textile
@@ -692,6 +692,19 @@ The method +String#squish+ strips leading and trailing whitespace, and substitut
There's also the destructive version +String#squish!+.
+h4. Key-based Interpolation
+
+In Ruby 1.9 the <tt>%</tt> string operator supports key-based interpolation, both formatted and unformatted:
+
+<ruby>
+"Total is %<total>.02f" % {:total => 43.1} # => Total is 43.10
+"I say %{foo}" % {:foo => "wadus"} # => "I say wadus"
+"I say %{woo}" % {:foo => "wadus"} # => KeyError
+</ruby>
+
+Active Support adds that functionality to <tt>%</tt> in previous versions of Ruby.
+
+
h3. Extensions to +Numeric+
...