Substitute

jQuery Substitute extension for jQuery 1.3+. It is assumed to work with pervious version of jQuery, however it is untested. Substitute replaces multiple string groups with other string groups.

Version:
1.1
Last Updated:
Jun 10, 2009
Requires:
jQuery 1.3+
Download:
http://freerksen.googlecode.com/files/jquery_substitute_1.1.zip

This jQuery extension is similar to the StringUtil.substitute method for Flex but based off of the Template.evaluate method for Prototype.

1
2
3
var myString = "This is a {test} to see if it {works}. This is only a {test}. Looks to be {work}ing.";
var myReplacements = {works:"is working", test:"demo", work:"function"};
$("body").append($.substitute(myString, myReplacements));

The previous example will output:

1
This is a demo to see if it is working. This is only a demo. Looks to be functioning.

History:
090525 – Extension started and completed. Initial release.
090610 – Update extension structure.

There are no comments

Add a Comment

Allowed tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">