1 // !code vendor/crayon/lib/crayon.js 2 // !code vendor/crayon/lib/escape.js 3 /** 4 * @class 5 * @namespace Holds functionality for escaping charactors. 6 * @requires crayon/lib/core.js 7 * @requires crayon/lib/escape.js 8 */ 9 Crayon.Tag = { 10 /** 11 * Retrurns a tag string. 12 * @param {String} name a tag name such as "p". 13 * @param [Object] options kev-value pairs for the tag attributes. The default is <tt>{}</tt>. 14 * @param [Boolean] open if true, the closer is excluded. The default is fasle. 15 * @param [Boolean] escape if true, the special chars in tag attributes specified by <tt>options</tt> is escaped. 16 */ 17 tag : function(name, options, open, escape){ 18 if( escape === undefined ){ 19 escape = true; 20 } 21 var str = "<" + name; 22 if(options){ 23 for(var attr_name in options){ 24 str += " " + attr_name + '="' + (escape ? h(options[attr_name]) : options[attr_name]) + '"'; 25 } 26 } 27 return str + (open ? ">" : "/>"); 28 }, 29 30 /** 31 * Retrurns a tag string. 32 * @param {String} name a tag name such as "p". 33 * @param {String or Function} content The text inserted into the tag. If a function is passed, the returned value is inserted. 34 * @param [Object] options kev-value pairs for the tag attributes. The default is <tt>{}</tt>. 35 * @param [Boolean] escape if true, the special chars in tag attributes specified by <tt>options</tt> is escaped. 36 */ 37 content_tag : function(name, content, options, escape){ 38 var str = tag(name, options, true, escape); 39 str += Crayon.isFunction(content) ? content() : content.toString(); 40 return str + "</" + name + ">"; 41 } 42 }; 43 44 if( !this.do_not_import_global ){ 45 Crayon.extend(this, Crayon.Tag); 46 }else{ 47 Crayon.extend(Crayon.Tag); 48 } 49