Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(macros): Remove {{DeprecatedGeneric}} and {{DeprecatedBadge}} #8199

Merged
merged 7 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions kumascript/macros/DeprecatedBadge.ejs

This file was deleted.

123 changes: 0 additions & 123 deletions kumascript/macros/DeprecatedGeneric.ejs

This file was deleted.

40 changes: 21 additions & 19 deletions kumascript/macros/Deprecated_Inline.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@
//
// Parameters:
//
// $0 Version of deprecation (optional).
//
// The version should be prepended with "html", "js", "css", or "gecko"
// to indicate which technology the version number refers to. For backward
// compatibility, unprefixed versions are assumed to refer to Gecko, but
// you shouldn't rely on this.

var str = $0;
var type = 0; // assume we want the text badge
// None

if (/^\d/.test($0)) {
str = "gecko" + $0;
} else {
type = 1; // switch to the icon indicator if no version specified
}
const title = mdn.localString({
"en-US": "Deprecated. Not for use in new websites.",
"ko": "지원이 중단되었습니다. 새로운 웹사이트에서 사용하지 마세요.",
"zh-CN": "已弃用。请不要在新的网站中使用。",
"zh-TW": "已棄用。請不要在新的網站中使用。"
});

if (str.length) {
%><%-await template('deprecatedGeneric', ["inline",str])%><%
} else {
%><%-await template('DeprecatedBadge', [type])%><%
}
const abbreviation = mdn.localString({
"en-US": "Deprecated",
"es": "Obsoleto",
"fr": "Obsolète",
"ja": "非推奨",
"ko": "지원이 중단되었습니다",
"ru": "Устарело",
"zh-CN": "已弃用",
"zh-TW": "已棄用"
});
%>

<abbr class="icon icon-deprecated" title="<%= title %>">
<span class="visually-hidden"><%= abbreviation %></span>
</abbr>
33 changes: 1 addition & 32 deletions kumascript/tests/macros/Deprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,8 @@ describeMacro("Deprecated_Inline", function () {
return assert.eventually.equal(
macro.call(),
`<abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites.">
<span class="visually-hidden">Deprecated</span>
<span class="visually-hidden">Deprecated</span>
</abbr>`
);
});
itMacro("HTML-prefixed version (en-US)", function (macro) {
return assert.eventually.equal(
macro.call("html4"),
`<span class="notecard inline deprecated" title="">Deprecated since <a href="/en-US/docs/HTML">HTML4</a></span>`
);
});
itMacro("JS-prefixed version (en-US)", function (macro) {
return assert.eventually.equal(
macro.call("js1.7"),
`<span class="notecard inline deprecated" title="">Deprecated since <a href="/en-US/docs/JavaScript/New_in_JavaScript/1.7">JavaScript 1.7</a></span>`
);
});
itMacro("CSS-prefixed version (en-US)", function (macro) {
return assert.eventually.equal(
macro.call("css2"),
`<span class="notecard inline deprecated" title="">Deprecated since CSS 2</span>`
);
});
itMacro("CSS-prefixed version (ja)", function (macro) {
macro.ctx.env.locale = "ja";
return assert.eventually.equal(
macro.call("css2"),
`<span class="notecard inline deprecated" title="">非推奨 CSS 2</span>`
);
});
itMacro("Nonsense-prefixed version (en-US)", function (macro) {
return assert.eventually.equal(
macro.call("foobar13"),
`<span class="notecard inline deprecated" title="">Deprecated</span>`
);
});
});