Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit a5fa6d7

Browse files
author
Florens Verschelde
committed
Enable Twig cache by default
1 parent 863e56c commit a5fa6d7

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

doc/options.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@ c::set('twig.usephp', true);
1313
// For instance 'error/system'. Falls back to c::get('error').
1414
c::set('twig.error', '');
1515

16+
// List of additional functions that should be available in templates
17+
c::set('twig.env.functions', ['myCustomFunction']);
18+
19+
// List of classes that can be instantiated from templates (with the `new()` function)
20+
c::set('twig.env.classes', ['SomeClass']);
21+
```
22+
23+
## Advanced
24+
25+
```
1626
// Use Twig’s PHP cache?
17-
// (Note that Kirby has its own HTML cache.)
18-
c::set('twig.cache', false);
27+
// Enabled by default. Note that Kirby has its own HTML cache for pages,
28+
// so this might be extra work, but for pages which are often not cached
29+
// (e.g. search pages with a specific query string) this could be useful.
30+
c::set('twig.cache', true);
1931
2032
// Disable autoescaping or specify autoescaping type
2133
// http://twig.sensiolabs.org/doc/api.html#environment-options
@@ -24,10 +36,4 @@ c::set('twig.autoescape', true);
2436
// Should Twig throw errors when using undefined variables or methods?
2537
// Defaults to the value of the 'debug' option
2638
c::set('twig.strict', c::get('debug', false));
27-
28-
// List of additional functions that should be available in templates
29-
c::set('twig.env.functions', ['myCustomFunction']);
30-
31-
// List of classes that can be instantiated from templates (with the `new()` function)
32-
c::set('twig.env.classes', ['SomeClass']);
3339
```

src/TwigRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function __construct()
124124
$options = [
125125
'debug' => $debug,
126126
'strict_variables' => C::get('twig.strict', $debug),
127-
'cache' => C::get('twig.cache', false) ? $cacheDir : false,
127+
'cache' => C::get('twig.cache', true) ? $cacheDir : false,
128128
'autoescape' => C::get('twig.autoescape', true)
129129
];
130130

0 commit comments

Comments
 (0)