Extension:TemplateStylesExtender
Appearance
From mediawiki.org
Release status: stable |
|
|---|---|
| Implementation | Parser extension |
| Description | Extends Extension:TemplateStyles with new selectors |
| Author(s) | Octfx talk |
| Latest version | 2.2.0 |
| Compatibility policy | Master maintains backward compatibility. |
| MediaWiki | >= 1.43.0 |
| PHP | >=8.0 |
| Database changes | No |
| Composer | octfx/template-styles-extender |
|
|
| Licence | GNU General Public License 2.0 or later |
| Download | |
The TemplateStylesExtender extension extends Extension:TemplateStyles with new selectors and matchers. TemplateStylesExtender is developed based on Css-sanitizer 5.5.0, which is being used by MediaWiki 1.43 .
Features
[edit ]- Declare CSS custom properties/variables
- Use CSS custom properties/variables in most properties
- Implement additional properties and values as listed below
Installation
[edit ]- Download and place the file(s) in a directory called
TemplateStylesExtenderin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'TemplateStyles' ); wfLoadExtension( 'TemplateStylesExtender' );
- Configure as required.
- Yes Done – Navigate to
Special:Versionon your wiki to verify that the extension is successfully installed.
Configuration
[edit ]| Configuration | Description | Default |
|---|---|---|
$wgTemplateStylesExtenderCustomPropertiesDeclaration
|
Allow CSS custom properties (CSS variables) to be declared as properties | true
|
$wgTemplateStylesExtenderExtendCustomPropertiesValues
|
Allow the CSS custom properties (CSS variables) to be used as values in all properties | true
|
$wgTemplateStylesExtenderEnableUnscopingSupport
|
Allows users with unscope permissions to unscope CSS by setting a wrapclass attribute.
|
false
|
$wgTemplateStylesExtenderUnscopingPermission
|
Specify a permission group that is allowed to unscope CSS. | editinterface
|
Note CSS Vars
[edit ]Currently using :root selectors won't work due to template styles prepending .mw-parser-output.
One possible fix is to wrap the entire content into a 'div' element and adding the declarations to this, e.g.
div#content-wrap{ --padding:10px } .content{ padding:var(--padding) }
Wikitext
<div id="content-wrap"> <div class="content"> The WikiText... </div> </div>
Unscoping of CSS
[edit ]Example: <templatestyles src="Foo/style.css" wrapclass="mediawiki" /> results in the CSS being scoped to .mediawiki instead of .mw-parser-output.
Including such a call in a page essentially limits editing to users with the
editinterface right. You can alternatively include a call to a template that includes the styles.See also
[edit ]Categories:
- Stable extensions
- Parser extensions
- Extensions supporting Composer
- ParserFirstCallInit extensions
- TemplateStylesPropertySanitizer extensions
- TemplateStylesStylesheetSanitizer extensions
- GPL licensed extensions
- Extensions in GitHub version control
- All extensions
- Extensions included in Canasta
- Extensions included in Miraheze
- Extensions included in MyWikis
- Extensions included in ProWiki
- Extensions included in Telepedia
- Extensions included in Weird Gloop
- Extensions included in wiki.gg