Template Architecture
The skin is built on MediaWiki’sSkinMustache framework, which provides a structured way to render skin components using Mustache templates.
Template Location
All templates are located in thetemplates/ directory:
Template Hierarchy
Templates use partials (sub-templates) to compose complex UI components:Key Templates
Header Template
The main header component containing site navigation. File:templates/Header.mustache
SkinCitizen::getTemplateData()
Drawer Template
The collapsible navigation drawer/sidebar. File:templates/Drawer.mustache
- Uses HTML
<details>for native expand/collapse - Conditionally renders site stats
- Includes main navigation menu
Footer Template
Page footer with site information and links. File:templates/Footer.mustache
Button Template
Reusable button component. File:templates/Button.mustache
Icon Template
SVG icon rendering. File:templates/Icon.mustache
skin.json skins.citizen.icons module)
Menu Template
Generic menu/dropdown component. File:templates/Menu.mustache
Template Data
Templates receive data from PHP through theSkinCitizen class.
Data Flow
Common Data Properties
| Property | Type | Description |
|---|---|---|
html-* | string | Raw HTML content (triple-mustache) |
msg-* | string | Localized message text |
data-* | object/array | Structured data objects |
array-* | array | Iterable lists |
is-* | boolean | Conditional flags |
link-* | string | URL/href values |
Example: Menu Data
Customizing Templates
Method 1: Override Templates
Create a child skin or extension that overrides specific templates:templates/ directory.
Method 2: Modify Template Data
Use hooks to modify the data passed to templates:Method 3: JavaScript Enhancement
Enhance templates with JavaScript after rendering:Template Patterns
Conditional Rendering
Iteration
Partials (Sub-templates)
Raw HTML
Creating Custom Components
1. Create the Template
2. Provide Template Data
3. Include in Parent Template
4. Add Styles
Template Best Practices
- Use semantic HTML - Use appropriate HTML5 elements
- Add ARIA labels - Ensure accessibility with proper ARIA attributes
- Follow naming conventions:
- Components:
ComponentName.mustache - Sub-components:
ComponentName__part.mustache
- Components:
- Document template data - Use Mustache comments to document expected data
- Keep templates focused - Break complex templates into smaller partials
- Avoid logic - Keep templates presentational; logic belongs in PHP
- Use CSS classes - Follow BEM naming:
.citizen-component__element--modifier
Template Comments
Document your templates with Mustache comments:Debugging Templates
Enable debug mode to see template data:Related
- Resource Loader - Loading template-related assets
- Theming - Styling template components
- MediaWiki SkinMustache - Base template system