1/* 2 * jQuery Simple Templates plugin 1.1.1 3 * 4 * http://andrew.hedges.name/tmpl/ 5 * http://docs.jquery.com/Plugins/Tmpl 6 * 7 * Copyright (c) 2008 Andrew Hedges, [email protected] 8 * 9 * Usage: $.tmpl('<div class="#{classname}">#{content}</div>', { 'classname' : 'my-class', 'content' : 'My content.' }); 10 * $.tmpl('<div class="#{1}">#{0}</div>', 'My content', 'my-class'); // placeholder order not important 11 * 12 * The changes for version 1.1 were inspired by the discussion at this thread: 13 * http://groups.google.com/group/jquery-ui/browse_thread/thread/45d0f5873dad0178/0f3c684499d89ff4 14 * 15 * Dual licensed under the MIT and GPL licenses: 16 * http://www.opensource.org/licenses/mit-license.php 17 * http://www.gnu.org/licenses/gpl.html 18 */ 19 20(function($) { 21 // regular expression for matching our placeholders; e.g., #{my-cLaSs_name77} 22 var regx = /#\{([^{}]*)}/g; 23 24 $.extend({ 25 // public interface: $.tmpl 26 tmpl : function(tmpl) { 27 // default to doing no harm 28 tmpl = tmpl || ''; 29 var vals = (2 === arguments.length && 'object' === typeof arguments[1] ? arguments[1] : Array.prototype.slice.call(arguments,1)); 30 // function to making replacements 31 var repr = function (str, match) { 32 return typeof vals[match] === 'string' || typeof vals[match] === 'number' ? vals[match] : str; 33 }; 34 35 return tmpl.replace(regx, repr); 36 } 37 }); 38})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.