Template:csscomputedshorthand

  • Revision slug: Template:csscomputedshorthand
  • Revision title: Template:csscomputedshorthand
  • Revision id: 361805
  • 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:
    '; for (i=0; i<values.length; i++)="" re="new" regexp("<\\s*(span|div)\\s+id\\s*="\\s*"+'"computed-'+values[i]+'"'+"[^" var="" {="">]*>(.*)<\\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 +'
  • '; } s_result += '</values.length;>
'; 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:<ul>';
for (i=0; i<values.length; i++)
{
    var re = new RegExp("<\\s*(span|div)\\s+id\\s*=\\s*"+'"computed-'+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>';
}
 
s_result += '</ul>';
 
var result = '<span id="computed-' + $0 + '">' + s_result + '</span>';
  
%><%- result %>
Revert to this revision