Here is a quick jQuery Plugin Announcement:

String concatenation and formatting are common aspects of almost every development effort. However, the combination of single and double quotes, along with escape characters, text, and plus signs (+) can be a bit overwhelming and difficult to remember. The .NET Framework provides a much cleaner approach with the String class's Format method. It allows you to create string values by specifying insertion points for other values as well as special formatting.

String.Format("Hello {0}", "world");

The string formatting approach described above can now be used with Javascript using a jQuery Plugin: .NET STYLE STRING FORMATTING - a simple and clever function to support token replacement within a string.

Given a string like "Hello, {0}" and calling the format function with a single argument like "world".

var result = $.format("Hello, {0}", "world");

The result variable will be set to "Hello, world".

The function will support an arbitrary number of arguments including none. When a token is unused in the string it will be ignored and too many arguments will be ignored.

More details can be found here.

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Comments

November 16. 2009 10:55

Social comments and analytics for this post

This post was mentioned on Twitter by bloggingdev: .NET Style String Formatting with jQuery - Function to Support Token Replacement within a String http://su.pr/6kdfOh

uberVU - social comments | Reply

Add comment




(Will not be displayed!)








SponsoredTweets referral badge
Free CMS