jansuchanek/ntheme

Theme resolver for Nette — active/fallback template resolution, asset paths

Maintainers

Package info

github.com/JanSuchanek/ntheme

pkg:composer/jansuchanek/ntheme

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-19 08:01 UTC

This package is auto-updated.

Last update: 2026-03-20 15:19:42 UTC


README

Theme management with active/fallback resolution chain. Resolves Latte templates and asset paths.

Installation

composer require jansuchanek/ntheme

Usage

use NTheme\ThemeResolver;

$resolver = new ThemeResolver(
    activeTheme: 'modern',
    fallbackTheme: 'default',
    themesDir: __DIR__ . '/themes',
);

// Get template paths (active first, then fallback)
$paths = $resolver->getTemplatePaths('Product', 'detail');
// ['/themes/modern/Product/detail.latte', '/themes/default/Product/detail.latte']

// Resolve first existing template
$file = $resolver->resolveTemplate('Product', 'detail');

// Layout resolution
$layout = $resolver->resolveLayout();

// Asset base URL
$css = $resolver->getAssetBaseUrl() . '/css/style.css';
// '/themes/modern/css/style.css'

// List available themes
$themes = $resolver->getAvailableThemes();
// ['default', 'modern', 'dark']

// Switch theme at runtime
$resolver->setActiveTheme('dark');

Directory Structure

themes/
├── default/
│   ├── @layout.latte
│   └── Product/
│       └── detail.latte
└── modern/
    ├── @layout.latte
    └── Product/
        └── detail.latte

Requirements

  • PHP >= 8.1