Extension:TemplateStyles/ja

TemplateStyles拡張機能は、Wikiマークアップ記法のページからCSSを読み込むことを可能にするためのタグを導入します. これをテンプレートに書くことで、に配置しなくてもテンプレートにカスタムCSSを影響させることができます.

拡張機能をWiki上でエディタとして使用する方法は、を参照してください.

使用法
まず、CSSページを作ってください. 規定では、「.css」で終わるテンプレート名前空間のサブページは、すべて、文法エラーがなければ「サニタイズ済みCSS」で作成されます.

名前空間の集合が で修正されるか、あるいはが任意のページで使用される場合があります. そして、Wikitextのテンプレートに タグを追加してCSSを読み込みます.

「サニタイズ済みCSS」コンテンツモデルを使用して保存されたCSSは厳密な妥当性要件を満たさなければなりません. 無効なCSS、認識されない@-規則、認識されない、あるいはサポートされないプロパティーまたはプロパティーの値は保存できません. 無効なCSSがなぜが保存されてしまった場合、そのCSSがブラウザに出力された際に問題のある内容は取り除かれます.

The value of the  attribute on the tag is the title of the page, defaulting to the Template namespace. (This default can be changed via .) For example,  will load the page "Template:Example/styles.css". This will fail if that page does not exist or has a content model other than "Sanitized CSS".

Styles can be scoped within the page by using the optional  parameter to the tag, e.g.   would scope the styles loaded to any   inside the main parsed content. Any CSS simple selector sequence can be used for the  parameter. This is intended to allow side-by-side comparison of live and sandbox versions of a template.

Use of sanitized CSS is tracked like transclusion of templates, and will show up as a transclusion on.

Caveats
Requests to support additional properties should be filed in Phabricator in the css-sanitizer and TemplateStyles projects. This should largely prevent redefining fonts used elsewhere in the document. Other classes on the  or   elements may be targeted in the same manner.
 * Styles added by TemplateStyles are scoped into  to avoid tampering with the user interface outside of the main parsed content.
 * To use TemplateStyles to style something like w:MediaWiki:Protectedpagetext, you would need to enclose the message's contents in.
 * The styles should be written to target specific CSS classes, and anything that generates elements with those classes should be sure to also include the styles itself rather than relying on some other template to have done so.
 * Styles included by a template can currently affect content on the page outside of the content generated by that template, but this ability may be removed in the future and should not be relied upon.
 * Including styles on a template that affects contents outside of that template, will cause those styles to not be applied when editing a section that doesn't contain that template. Example: including styles on an infobox that affect all tables of the page, when editing a section that doesn't contain the infobox, those tables won't be styled when previewing that section.
 * TemplateStyles allows few non-standardized CSS properties.
 * Requests should include links to standards-track documents (e.g. on w3.org) describing the syntax of the properties being requested, and an analysis of current browser support for the properties (e.g. a link to a caniuse.com page about the properties).
 * Vendor-prefixed properties (e.g. anything starting with,  , or  ) are likely to be declined if they're not needed for modern browsers.
 * rules must use a  prefixed with "TemplateStyles".
 * To target styles based on skins, use a selector such as ; specification of the   element is required and must be followed by a descendant combinator (i.e. the space).

その他の依存関係
should be configured to use no tidying or RemexHtml. If used with any of the Raggett drivers, a tag in the middle of a paragraph (including in an inline template) will cause tidy to break the paragraph at that point. The other drivers have not been tested for this issue.

潜在的なエラー
If you experience an error when importing pages from another wiki, for example, it may help to enable in your   to determine if you are experiencing any of the errors below.


 * This error may come up when attempting to import a wiki CSS page or when changing the content model of a page to "santized-css". There is, as of April 16, 2020, an open bug in the extension distributor which requires  to be run in the extension subdirectory even when the extension is not installed from Git. 詳細は Topic:Ukv6pdo96a8qfur2 を参照してください.
 * Some people get this error on a wiki when importing pages. This extension provides that content model. Install TemplateStyles to fix your import.
 * Some people get this error on a wiki when importing pages. This extension provides that content model. Install TemplateStyles to fix your import.
 * Some people get this error on a wiki when importing pages. This extension provides that content model. Install TemplateStyles to fix your import.

関連項目

 * - used for the sanitization of the CSS.
 * T483 "RfC: Allow styling in templates" (about possibly deploying this extension on Wikimedia wikis)
 * Requests for comment/Allow styling in templates
 * T56864 "ResourceLoader: Implement support for LESS in wiki modules (user and site), supporting e.g. MediaWiki:Common.less"
 * T155813 "Decide on storage and delivery method for TemplateStyles CSS"
 * It’s now easier to craft content for mobile devices: Responsive web design at the Wikipedia scale on the Wikimedia Blog.
 * It’s now easier to craft content for mobile devices: Responsive web design at the Wikipedia scale on the Wikimedia Blog.