Template:cssappliestoshorthand

<%
// $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/CSS/CSS_values_serialization",
    "de": "de/docs/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 jeweiligen Kurzschreibweisen:<ul>'
});

for (var i = 0, len = values.length; i < len; 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 (!value) { // If not found, it is a shorthand itself
        value = "is itself a shorthand, applies to the same elements as each of its longhand properties.";

        /*
         *  In some languages, problems arise in this way.
         *  You should do like... : "str1 + xxx + str2"
         */

    } 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="appliesto-' + $0 + '">' + s_result + '</span>';


%><%- result %>
Search for pages that use Template:cssappliestoshorthand to see example use cases and how many pages use this macro.

Document Tags and Contributors

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