ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
FileExtensionEscapingStrategy.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
24{
32 public static function guess($name)
33 {
34 if (in_array(substr($name, -1), array('/', '\\'))) {
35 return 'html'; // return html for directories
36 }
37
38 if ('.twig' === substr($name, -5)) {
39 $name = substr($name, 0, -5);
40 }
41
42 $extension = pathinfo($name, PATHINFO_EXTENSION);
43
44 switch ($extension) {
45 case 'js':
46 return 'js';
47
48 case 'css':
49 return 'css';
50
51 case 'txt':
52 return false;
53
54 default:
55 return 'html';
56 }
57 }
58}
59
60class_alias('Twig_FileExtensionEscapingStrategy', 'Twig\FileExtensionEscapingStrategy', false);
An exception for terminatinating execution or to throw for unit testing.
Default autoescaping strategy based on file names.
static guess($name)
Guesses the best autoescaping strategy based on the file name.
if($format !==null) $name
Definition: metadata.php:146