mozilla

Revision 362913 of Template:cssappliestoshorthand

  • Revision slug: Template:cssappliestoshorthand
  • Revision title: Template:cssappliestoshorthand
  • Revision id: 362913
  • 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 = []; 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" })); var s_result = mdn.localString({ "en-US": 'as each of the properties of the shorthand:
    ', "fr": 'comme chacune des propriétés du raccourci:
      ' }); 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 += '
    • ' + values[i] + ': ' + value +'
    • '; } 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 = [];

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"
}));

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>'
});

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 %>