Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
c6f3f8cc
Commit
c6f3f8cc
authored
Aug 24, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made it possible to use both paths and templates defined in arrays for the Twig extension
parent
3a76a3a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
doc/extensions/twig.rst
doc/extensions/twig.rst
+4
-6
src/Silex/Extension/TwigExtension.php
src/Silex/Extension/TwigExtension.php
+4
-5
No files found.
doc/extensions/twig.rst
View file @
c6f3f8cc
...
...
@@ -7,13 +7,11 @@ The *TwigExtension* provides integration with the `Twig
Parameters
----------
* **twig.path**: Path to the directory containing twig template
files.
* **twig.path**
(optional)
: Path to the directory containing twig template
files
(it can also be an array of paths)
.
* **twig.templates** (optional): If this option is provided
you don't have to provide a ``twig.path``. It is an
associative array of template names to template contents.
Use this if you want to define your templates inline.
* **twig.templates** (optional): An associative array of template names to
template contents. Use this if you want to define your templates inline.
* **twig.options** (optional): An associative array of twig
options. Check out the twig documentation for more information.
...
...
src/Silex/Extension/TwigExtension.php
View file @
c6f3f8cc
...
...
@@ -61,11 +61,10 @@ class TwigExtension implements ExtensionInterface
});
$app
[
'twig.loader'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
if
(
isset
(
$app
[
'twig.templates'
]))
{
return
new
\Twig_Loader_Array
(
$app
[
'twig.templates'
]);
}
else
{
return
new
\Twig_Loader_Filesystem
(
$app
[
'twig.path'
]);
}
return
new
\Twig_Loader_Chain
(
array
(
new
\Twig_Loader_Filesystem
(
isset
(
$app
[
'twig.path'
])
?
$app
[
'twig.path'
]
:
array
()),
new
\Twig_Loader_Array
(
isset
(
$app
[
'twig.templates'
])
?
$app
[
'twig.templates'
]
:
array
()),
));
});
if
(
isset
(
$app
[
'twig.class_path'
]))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment