mozilla

Revision 360043 of Template:cssappliestoshorthand

  • Revision slug: Template:cssappliestoshorthand
  • Revision title: Template:cssappliestoshorthand
  • Revision id: 360043
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

<% // $0 is the name of the definition (property or data type), without < > or '' // $1 is a string containing the list of the associated longhand properties // Read the word of the parameters one by one and store them in an array var regexp = /([\w-]+)/g; var values = new Array(); while ((elt=regexp.exec($1)) != null) { values.push(elt[1]); } // Load the whole page (wiki.page does cache the original page var page = wiki.page(mdn.localString({ "en-US": "en-US/docs/CSS/CSS_values_serialization" })); var s_result = 'As each of the properties of the shorthand:\n
    \n'; for (i=0; i]*>(.*)<\\s*/\\s*(span|div)\\s*\\>","igm"); var value = re.exec(page); // If not found, it is a shorthand itself if (!value) { value = "is itself a shorthand, applies to the same elements as each of its longhand properties."; } else { // Found. We keep only the value value = value[2]; } s_result += '
  • ' + values[i] + ': ' + value +'
  • \n'; } s_result += '
'; var result = '' + s_result + ''; %><%- result %>

Revision Source

<%
// $0 is the name of the definition (property or data type), without < > or ''
// $1 is a string containing the list of the associated longhand properties

// Read the word of the parameters one by one and store them in an array
var regexp = /([\w-]+)/g;
var values = new Array();
while ((elt=regexp.exec($1)) != null) {
    values.push(elt[1]);
}

// Load the whole page (wiki.page does cache the original page
var page = wiki.page(mdn.localString({
    "en-US": "en-US/docs/CSS/CSS_values_serialization"
}));
 
var s_result = 'As each of the properties of the shorthand:\n<ul>\n';
for (i=0; i<values.length; i++)
{
    var re = new RegExp("<\\s*(span|div)\\s+id\\s*=\\s*"+'"appliesto-'+values[i]+'"'+"[^>]*>(.*)<\\s*/\\s*(span|div)\\s*\\>","igm");
    var value = re.exec(page);

    // If not found, it is a shorthand itself
    if (!value) {
        value = "is itself a shorthand, applies to the same elements as each of its longhand properties.";    
    }
    else { // Found. We keep only the value
        value = value[2];
    }

    s_result += '<li><code>' + values[i] + '</code>: ' + value +'</li>\n';
}

s_result += '</ul>';

var result = '<span id="appliesto-' + $0 + '">' + s_result + '</span>';
 
%><%- result %>
Revert to this revision