B2G/gecko/testing/mochitest/server.js
/**
 * Below, we'll use makeTagFunc to create a function for each of the
 * strings in 'tags'. This will allow us to use s-expression like syntax
 * to create HTML.
 */
Below, we'll use makeTagFunc to create a function for each of the
strings in 'tags'. This will allow us to use s-expression like syntax
to create HTML.
Below we ' ll use makeTagFunc to create a function for each of the strings in ' tags ' . This will allow us to use s - expression like syntax to create HTML .
function makeTagFunc(tagName)
{
  return function (attrs )
  {
    var startChildren = 0;
    var response = "";
    response += "<" + tagName;
    if (attrs && typeof attrs == 'object') {
      startChildren = 1;
      for (var [key,value] in attrs) {
        var val = "" + value;
        response += " " + key + '="' + val.replace('"','&quot;') + '"';
      }
    }
    response += ">";
    for (var i = startChildren; i < arguments.length; i++) {
      if (typeof arguments[i] == 'function') {
        response += arguments[i]();
      } else {
        response += arguments[i];
      }
    }
    response += "</" + tagName + ">\n";
    return response;
  }
}
function makeTagFunc ( tagName ) { return function ( attrs ) { var startChildren = 0 ; var response = "" ; response += "<" + tagName ; if ( attrs && typeof attrs == 'object' ) { startChildren = 1 ; for ( var [ key , value ] in attrs ) { var val = "" + value ; response += " " + key + '="' + val . replace ( '"' , '&quot;' ) + '"' ; } } response += ">" ; for ( var i = startChildren ; i < arguments . length ; i ++ ) { if ( typeof arguments [ i ] == 'function' ) { response += arguments [ i ] ( ) ; } else { response += arguments [ i ] ; } } response += "</" + tagName + ">\n" ; return response ; } }
Below, we'll use makeTagFunc to create a function for each of the
 strings in 'tags'.
Below we ' ll use makeTagFunc to create a function for each of the strings in ' tags ' .
/* rest... */ // write the start tag and attributes // if attr is an object, write attributes // iterate through the rest of the args // write the close tag