@@ -99,15 +99,23 @@ private function getCallableReflector($callable)
99
99
100
100
private function getTemplateSource (\Twig_Template $ template )
101
101
{
102
+ // Twig templates are not always stored in files, and so there is no
103
+ // API to get the filename from a template name in a generic way.
104
+ // The logic used here works only for templates stored in app/Resources/views
105
+ // and referenced via the "filename.html.twig" notation, not via the "::filename.html.twig"
106
+ // one or stored in bundles. This is enough for the needs of the demo app.
107
+ $ filePath = $ this ->kernelRootDir .'/Resources/views/ ' .$ template ->getTemplateName ();
108
+ $ sourceCode = $ template ->getSource ();
109
+
110
+ // Temporary workaround for https://github.com/twigphp/Twig/issues/2011
111
+ if (null === $ sourceCode ) {
112
+ $ sourceCode = @file_get_contents ($ filePath );
113
+ }
114
+
102
115
return [
103
- // Twig templates are not always stored in files, and so there is no
104
- // API to get the filename from a template name in a generic way.
105
- // The logic used here works only for templates stored in app/Resources/views
106
- // and referenced via the "filename.html.twig" notation, not via the "::filename.html.twig"
107
- // one or stored in bundles. This is enough for the needs of the demo app.
108
- 'file_path ' => $ this ->kernelRootDir .'/Resources/views/ ' .$ template ->getTemplateName (),
116
+ 'file_path ' => $ filePath ,
109
117
'starting_line ' => 1 ,
110
- 'source_code ' => $ template -> getSource () ,
118
+ 'source_code ' => $ sourceCode ,
111
119
];
112
120
}
113
121
0 commit comments