Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (37 sloc) 1.17 KB
<%
/*
Inserts a link to an HTML element documentation
Appropriate styling is applied.
Parameters:
$0 - Element name
$1 - Text to display (optional)
$2 - Anchor within the page (optional)
*/
var elementName = $0.toString().toLowerCase();
var linkText = ($1 || elementName);
switch (env.locale) {
case 'ja':
if (elementName === linkText && elementName.indexOf(" 要素") !== -1){
elementName = linkText.replace(" 要素","");
}
break;
default: break;
}
var commonLocalStrings = string.deserialize(template("L10n:Common"));
var sectionName = mdn.localString({
"es": "Elemento",
"en-US": "Element"
});
var url = "/" + env.locale + "/docs/Web/HTML/" + sectionName + "/" +
elementName;
var page = wiki.getPage(url);
var summary = (page && page.summary) ? mdn.escapeQuotes(page.summary) :
mdn.getLocalString(commonLocalStrings, "summary");
// Add anchor after fetching the page contents
url += $2;
if (linkText === elementName && elementName.indexOf(" ") === -1) {
linkText = "<code>&lt;" + linkText + "&gt;</code>";
}
var link = "<a href=\"" + url + "\" title=\"" + summary + "\">" + linkText +
"</a>";
%><%- link %>