Template:csscomputedshorthand

by 3 contributors:

This article is in need of a technical review.

<%
// $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 = [];

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",
    "fr"   : "fr/docs/CSS/CSS_values_serialization",
    "ja"   : "ja/docs/Web/CSS/CSS_values_serialization",
    "de"   : "de/docs/Web/CSS/CSS_Werte_Geltung"
}));
  
var s_result = mdn.localString({
    "en-US": 'as each of the properties of the shorthand:<ul>',
    "fr"   : "comme chacune des propriétés du raccourci:<ul>",
    "de"   : "wie die einzelnen Werte der Kurzschreibweise:<ul>"
});

for (var 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 %>
Search for pages that use Template:csscomputedshorthand to see example use cases and how many pages use this macro.

Document Tags and Contributors

Contributors to this page: teoli, SJW, ethertank
Last updated by: teoli,