Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cab4b74

Browse files
committed
docs: Update CommentTemplate documentation across all languages
1 parent 1706eb1 commit cab4b74

File tree

12 files changed

+1317
-107
lines changed

12 files changed

+1317
-107
lines changed

content/v3/de/awesome-plugins/comment_template.md

Lines changed: 107 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ use KnifeLemon\CommentTemplate\Engine;
3333
$app = Flight::app();
3434

3535
$app->register('view', Engine::class, [], function (Engine $engine) use ($app) {
36-
// Wo Ihre Template-Dateien gespeichert sind
37-
$engine->setTemplatesPath(__DIR__ . '/views');
36+
// Wurzelverzeichnis (wo sich index.php befindet) - das Document Root Ihrer Webanwendung
37+
$engine->setPublicPath(__DIR__);
3838

39-
// Wo Ihre öffentlichen Assets serviert werden
40-
$engine->setPublicPath(__DIR__ . '/public');
39+
// Template-Dateiverzeichnis - unterstützt relative und absolute Pfade
40+
$engine->setSkinPath('views'); // Relativ zum öffentlichen Pfad
4141

42-
// Wo kompilierte Assets gespeichert werden
43-
$engine->setAssetPath('assets');
42+
// Wo kompilierte Assets gespeichert werden - unterstützt relative und absolute Pfade
43+
$engine->setAssetPath('assets'); // Relativ zum öffentlichen Pfad
4444

4545
// Template-Dateierweiterung
4646
$engine->setFileExtension('.php');
@@ -63,9 +63,9 @@ $app = Flight::app();
6363

6464
// __construct(string $publicPath = "", string $skinPath = "", string $assetPath = "", string $fileExtension = "")
6565
$app->register('view', Engine::class, [
66-
__DIR__ . '/public', // publicPath - wo Assets serviert werden
67-
__DIR__ . '/views', // skinPath - wo Template-Dateien gespeichert sind
68-
'assets', // assetPath - wo kompilierte Assets gespeichert werden
66+
__DIR__, // publicPath - Wurzelverzeichnis (wo index.php ist)
67+
'views', // skinPath - Template-Pfad (unterstützt relativ/absolut)
68+
'assets', // assetPath - kompilierter Asset-Pfad (unterstützt relativ/absolut)
6969
'.php' // fileExtension - Template-Dateierweiterung
7070
]);
7171

@@ -74,6 +74,83 @@ $app->map('render', function(string $template, array $data) use ($app): void {
7474
});
7575
```
7676

77+
## Pfad-Konfiguration
78+
79+
CommentTemplate bietet intelligente Pfad-Behandlung für relative und absolute Pfade:
80+
81+
### Öffentlicher Pfad
82+
83+
Der **Öffentliche Pfad** ist das Wurzelverzeichnis Ihrer Webanwendung, typischerweise wo sich `index.php` befindet. Dies ist das Document Root, von dem Webserver Dateien bereitstellen.
84+
85+
```php
86+
// Beispiel: wenn Ihre index.php bei /var/www/html/myapp/index.php liegt
87+
$template->setPublicPath('/var/www/html/myapp'); // Wurzelverzeichnis
88+
89+
// Windows-Beispiel: wenn Ihre index.php bei C:\xampp\htdocs\myapp\index.php liegt
90+
$template->setPublicPath('C:\\xampp\\htdocs\\myapp');
91+
```
92+
93+
### Template-Pfad-Konfiguration
94+
95+
Template-Pfad unterstützt sowohl relative als auch absolute Pfade:
96+
97+
```php
98+
$template = new Engine();
99+
$template->setPublicPath('/var/www/html/myapp'); // Wurzelverzeichnis (wo index.php ist)
100+
101+
// Relative Pfade - automatisch mit öffentlichem Pfad kombiniert
102+
$template->setSkinPath('views'); // → /var/www/html/myapp/views/
103+
$template->setSkinPath('templates/pages'); // → /var/www/html/myapp/templates/pages/
104+
105+
// Absolute Pfade - wie sie sind verwendet (Unix/Linux)
106+
$template->setSkinPath('/var/www/templates'); // → /var/www/templates/
107+
$template->setSkinPath('/full/path/to/templates'); // → /full/path/to/templates/
108+
109+
// Windows absolute Pfade
110+
$template->setSkinPath('C:\\www\\templates'); // → C:\www\templates\
111+
$template->setSkinPath('D:/projects/templates'); // → D:/projects/templates/
112+
113+
// UNC-Pfade (Windows-Netzwerkfreigaben)
114+
$template->setSkinPath('\\\\server\\share\\templates'); // → \\server\share\templates\
115+
```
116+
117+
### Asset-Pfad-Konfiguration
118+
119+
Asset-Pfad unterstützt auch sowohl relative als auch absolute Pfade:
120+
121+
```php
122+
// Relative Pfade - automatisch mit öffentlichem Pfad kombiniert
123+
$template->setAssetPath('assets'); // → /var/www/html/myapp/assets/
124+
$template->setAssetPath('static/files'); // → /var/www/html/myapp/static/files/
125+
126+
// Absolute Pfade - wie sie sind verwendet (Unix/Linux)
127+
$template->setAssetPath('/var/www/cdn'); // → /var/www/cdn/
128+
$template->setAssetPath('/full/path/to/assets'); // → /full/path/to/assets/
129+
130+
// Windows absolute Pfade
131+
$template->setAssetPath('C:\\www\\static'); // → C:\www\static\
132+
$template->setAssetPath('D:/projects/assets'); // → D:/projects/assets/
133+
134+
// UNC-Pfade (Windows-Netzwerkfreigaben)
135+
$template->setAssetPath('\\\\server\\share\\assets'); // → \\server\share\assets\
136+
```
137+
138+
**Intelligente Pfad-Erkennung:**
139+
140+
- **Relative Pfade**: Keine führenden Trennzeichen (`/`, `\`) oder Laufwerksbuchstaben
141+
- **Unix Absolut**: Beginnt mit `/` (z.B. `/var/www/assets`)
142+
- **Windows Absolut**: Beginnt mit Laufwerksbuchstabe (z.B. `C:\www`, `D:/assets`)
143+
- **UNC-Pfade**: Beginnt mit `\\` (z.B. `\\server\share`)
144+
145+
**Wie es funktioniert:**
146+
147+
- Alle Pfade werden automatisch basierend auf dem Typ aufgelöst (relativ vs absolut)
148+
- Relative Pfade werden mit dem öffentlichen Pfad kombiniert
149+
- `@css` und `@js` erstellen minifizierte Dateien in: `{resolvedAssetPath}/css/` oder `{resolvedAssetPath}/js/`
150+
- `@asset` kopiert einzelne Dateien nach: `{resolvedAssetPath}/{relativePath}`
151+
- `@assetDir` kopiert Verzeichnisse nach: `{resolvedAssetPath}/{relativePath}`
152+
- Intelligente Zwischenspeicherung: Dateien werden nur kopiert, wenn die Quelle neuer ist als das Ziel
153+
77154
## Template-Direktiven
78155

79156
### Layout-Vererbung
@@ -227,11 +304,31 @@ const imageData = '<!--@base64(images/icon.png)-->';
227304
{$name|concat= (Admin)} <!-- Text anhängen -->
228305
```
229306

230-
#### Variablenbefehle
307+
#### Mehrere Filter verketten
231308
```html
232309
{$content|striptag|trim|escape} <!-- Mehrere Filter ketten -->
233310
```
234311

312+
### Kommentare
313+
314+
Template-Kommentare werden vollständig aus der Ausgabe entfernt und erscheinen nicht im finalen HTML:
315+
316+
```html
317+
{* Dies ist ein einzeiliger Template-Kommentar *}
318+
319+
{*
320+
Dies ist ein mehrzeiliger
321+
Template-Kommentar
322+
über mehrere Zeilen
323+
*}
324+
325+
<h1>{$title}</h1>
326+
{* Debug-Kommentar: Prüfen ob title-Variable funktioniert *}
327+
<p>{$content}</p>
328+
```
329+
330+
**Hinweis**: Template-Kommentare `{* ... *}` unterscheiden sich von HTML-Kommentaren `<!-- ... -->`. Template-Kommentare werden während der Verarbeitung entfernt und erreichen nie den Browser.
331+
235332
## Beispiel-Projektstruktur
236333

237334
```

content/v3/en/awesome-plugins/comment_template.md

Lines changed: 106 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ use KnifeLemon\CommentTemplate\Engine;
3333
$app = Flight::app();
3434

3535
$app->register('view', Engine::class, [], function (Engine $engine) use ($app) {
36-
// Where your template files are stored
37-
$engine->setTemplatesPath(__DIR__ . '/views');
36+
// Root directory (where index.php is) - the document root of your web application
37+
$engine->setPublicPath(__DIR__);
3838

39-
// Where your public assets will be served from
40-
$engine->setPublicPath(__DIR__ . '/public');
39+
// Template files directory - supports both relative and absolute paths
40+
$engine->setSkinPath('views'); // Relative to public path
4141

42-
// Where compiled assets will be stored
43-
$engine->setAssetPath('assets');
42+
// Where compiled assets will be stored - supports both relative and absolute paths
43+
$engine->setAssetPath('assets'); // Relative to public path
4444

4545
// Template file extension
4646
$engine->setFileExtension('.php');
@@ -63,9 +63,9 @@ $app = Flight::app();
6363

6464
// __construct(string $publicPath = "", string $skinPath = "", string $assetPath = "", string $fileExtension = "")
6565
$app->register('view', Engine::class, [
66-
__DIR__ . '/public', // publicPath - where assets will be served from
67-
__DIR__ . '/views', // skinPath - where template files are stored
68-
'assets', // assetPath - where compiled assets will be stored
66+
__DIR__, // publicPath - root directory (where index.php is)
67+
'views', // skinPath - templates path (supports relative/absolute)
68+
'assets', // assetPath - compiled assets path (supports relative/absolute)
6969
'.php' // fileExtension - template file extension
7070
]);
7171

@@ -74,6 +74,83 @@ $app->map('render', function(string $template, array $data) use ($app): void {
7474
});
7575
```
7676

77+
## Path Configuration
78+
79+
CommentTemplate provides intelligent path handling for both relative and absolute paths:
80+
81+
### Public Path
82+
83+
The **Public Path** is the root directory of your web application, typically where `index.php` resides. This is the document root that web servers serve files from.
84+
85+
```php
86+
// Example: if your index.php is at /var/www/html/myapp/index.php
87+
$template->setPublicPath('/var/www/html/myapp'); // Root directory
88+
89+
// Windows example: if your index.php is at C:\xampp\htdocs\myapp\index.php
90+
$template->setPublicPath('C:\\xampp\\htdocs\\myapp');
91+
```
92+
93+
### Templates Path Configuration
94+
95+
Templates path supports both relative and absolute paths:
96+
97+
```php
98+
$template = new Engine();
99+
$template->setPublicPath('/var/www/html/myapp'); // Root directory (where index.php is)
100+
101+
// Relative paths - automatically combined with public path
102+
$template->setSkinPath('views'); // → /var/www/html/myapp/views/
103+
$template->setSkinPath('templates/pages'); // → /var/www/html/myapp/templates/pages/
104+
105+
// Absolute paths - used as-is (Unix/Linux)
106+
$template->setSkinPath('/var/www/templates'); // → /var/www/templates/
107+
$template->setSkinPath('/full/path/to/templates'); // → /full/path/to/templates/
108+
109+
// Windows absolute paths
110+
$template->setSkinPath('C:\\www\\templates'); // → C:\www\templates\
111+
$template->setSkinPath('D:/projects/templates'); // → D:/projects/templates/
112+
113+
// UNC paths (Windows network shares)
114+
$template->setSkinPath('\\\\server\\share\\templates'); // → \\server\share\templates\
115+
```
116+
117+
### Asset Path Configuration
118+
119+
Asset path also supports both relative and absolute paths:
120+
121+
```php
122+
// Relative paths - automatically combined with public path
123+
$template->setAssetPath('assets'); // → /var/www/html/myapp/assets/
124+
$template->setAssetPath('static/files'); // → /var/www/html/myapp/static/files/
125+
126+
// Absolute paths - used as-is (Unix/Linux)
127+
$template->setAssetPath('/var/www/cdn'); // → /var/www/cdn/
128+
$template->setAssetPath('/full/path/to/assets'); // → /full/path/to/assets/
129+
130+
// Windows absolute paths
131+
$template->setAssetPath('C:\\www\\static'); // → C:\www\static\
132+
$template->setAssetPath('D:/projects/assets'); // → D:/projects/assets/
133+
134+
// UNC paths (Windows network shares)
135+
$template->setAssetPath('\\\\server\\share\\assets'); // → \\server\share\assets\
136+
```
137+
138+
**Smart Path Detection:**
139+
140+
- **Relative Paths**: No leading separators (`/`, `\`) or drive letters
141+
- **Unix Absolute**: Starts with `/` (e.g., `/var/www/assets`)
142+
- **Windows Absolute**: Starts with drive letter (e.g., `C:\www`, `D:/assets`)
143+
- **UNC Paths**: Starts with `\\` (e.g., `\\server\share`)
144+
145+
**How it works:**
146+
147+
- All paths are automatically resolved based on type (relative vs absolute)
148+
- Relative paths are combined with the public path
149+
- `@css` and `@js` create minified files in: `{resolvedAssetPath}/css/` or `{resolvedAssetPath}/js/`
150+
- `@asset` copies single files to: `{resolvedAssetPath}/{relativePath}`
151+
- `@assetDir` copies directories to: `{resolvedAssetPath}/{relativePath}`
152+
- Smart caching: files only copied when source is newer than destination
153+
77154
## Template Directives
78155

79156
### Layout Inheritance
@@ -232,6 +309,26 @@ const imageData = '<!--@base64(images/icon.png)-->';
232309
{$content|striptag|trim|escape} <!-- Chain multiple filters -->
233310
```
234311

312+
### Comments
313+
314+
Template comments are completely removed from the output and won't appear in the final HTML:
315+
316+
```html
317+
{* This is a single-line template comment *}
318+
319+
{*
320+
This is a multi-line
321+
template comment
322+
that spans several lines
323+
*}
324+
325+
<h1>{$title}</h1>
326+
{* Debug comment: checking if title variable works *}
327+
<p>{$content}</p>
328+
```
329+
330+
**Note**: Template comments `{* ... *}` are different from HTML comments `<!-- ... -->`. Template comments are removed during processing and never reach the browser.
331+
235332
## Example Project Structure
236333

237334
```

0 commit comments

Comments
 (0)