mozilla

Revision 335535 of Template:subpagesSummary

  • Revision slug: Template:subpagesSummary
  • Revision title: Template:subpagesSummary
  • Revision id: 335535
  • Created:
  • Creator: madarche
  • Is current revision? No
  • Comment

Revision Content

<% /* The list of template's arguments is used to know which subpages title should not be marked as code */ var notCodeElements = arguments; /* To include the subpage summary, we need to know which local slug/hash to use with wiki.page */ var summary = mdn.localString({ "en-US": "Summary", "fr": "Résumé", "ja": "概要" }); var pageSubPages = page.subpages('',1); // Old version using String#concat /* var str = ''; if (pageSubPages) { var subPages = pageSubPages.subpages; str += '
'; for (var page in subPages) { str += '
'; if(notCodeElements.indexOf(subPages[page].title) < 0) { str += '' + subPages[page].title + ''; } else { str += subPages[page].title; } str += '
'; str += '
' + wiki.page(subPages[page].url, summary) + '
'; } str += '
'; } */ var list = []; if (pageSubPages) { var subPages = pageSubPages.subpages; list.push('
'); for (var page in subPages) { list.push('
'); if (notCodeElements.indexOf(subPages[page].title) < 0) { list.push(''); list.push(subPages[page].title); list.push(''); } else { list.push(subPages[page].title); } list.push('
'); list.push('
'); list.push(wiki.page(subPages[page].url, summary)); list.push('
'); } list.push('
'); } list.push('

TEST

'); %> <%- list.join('') %>

Revision Source

<%
/* The list of template's arguments is used to know which subpages title should not be marked as code */
var notCodeElements = arguments;
  
/* To include the subpage summary, we need to know which local slug/hash to use with wiki.page */
var summary = mdn.localString({
    "en-US": "Summary",
    "fr": "Résumé",
    "ja": "概要"
});
  
var pageSubPages = page.subpages('',1);
// Old version using String#concat
/*
var str = '';
if (pageSubPages) {
    var subPages = pageSubPages.subpages;
    str += '<dl>';
    for (var page in subPages) {
        str += '<dt><a href="' + subPages[page].url + '">';
        if(notCodeElements.indexOf(subPages[page].title) < 0) {
            str += '<code>' + subPages[page].title + '</code>';
        } else {
            str += subPages[page].title;
        }
        str += '</a></dt>';
        str += '<dd>' + wiki.page(subPages[page].url, summary) + '</dd>';
    }
    str += '</dl>';
}
*/
var list = [];
if (pageSubPages) {
    var subPages = pageSubPages.subpages;
    list.push('<dl>');
    for (var page in subPages) {
        list.push('<dt><a href="');
        list.push(subPages[page].url)
        list.push('">');
        if (notCodeElements.indexOf(subPages[page].title) < 0) {
            list.push('<code>');
            list.push(subPages[page].title);
            list.push('</code>');
        } else {
            list.push(subPages[page].title);
        }
        list.push('</a></dt>');
        list.push('<dd>');
        list.push(wiki.page(subPages[page].url, summary));
        list.push('</dd>');
    }
    list.push('</dl>');
}
list.push('<p>TEST</p>');
%>
<%- list.join('') %>