Skip to content
Snippets Groups Projects
Unverified Commit f9d9f6cd authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

Add support for our custom module path formats in the new Twig template loader.

Now we can load templates in twig with two syntaxes:

- The original twig syntax: "@module/path/to/template.twig"
- The SSP syntax: "module:path/to/template.php" or "module:path/to/template.tpl.php"
parent 0c2b92b4
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,22 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader ...@@ -25,6 +25,22 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader
return parent::findTemplate($name); return parent::findTemplate($name);
} }
protected function parseName($name, $default = self::MAIN_NAMESPACE)
{
if (strpos($name, ':')) {
// we have our old SSP format
list($namespace, $shortname) = explode(':', $name, 2);
$shortname = strtr($shortname, array(
'.tpl.php' => '.twig',
'.php' => '.twig',
));
return array($namespace, $shortname);
}
return parent::parseName($name, $default);
}
/** /**
* Get the template directory of a module, if it exists. * Get the template directory of a module, if it exists.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment