@@ -32,7 +32,7 @@ class HIncludeRenderingStrategy extends GeneratorAwareRenderingStrategy
32
32
*
33
33
* @param EngineInterface|\Twig_Environment $templating An EngineInterface or a \Twig_Environment instance
34
34
* @param UriSigner $signer A UriSigner instance
35
- * @param string $globalDefaultTemplate The content of the global default template
35
+ * @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
36
36
*/
37
37
public function __construct ($ templating , UriSigner $ signer = null , $ globalDefaultTemplate = null )
38
38
{
@@ -47,6 +47,10 @@ public function __construct($templating, UriSigner $signer = null, $globalDefaul
47
47
48
48
/**
49
49
* {@inheritdoc}
50
+ *
51
+ * Additional available options:
52
+ *
53
+ * * default: The default content (it can be a template name or the content)
50
54
*/
51
55
public function render ($ uri , Request $ request = null , array $ options = array ())
52
56
{
@@ -58,31 +62,14 @@ public function render($uri, Request $request = null, array $options = array())
58
62
$ uri = $ this ->signer ->sign ($ this ->generateProxyUri ($ uri , $ request ));
59
63
}
60
64
61
- $ defaultTemplate = isset ($ options ['default ' ]) ? $ options ['default ' ] : null ;
62
- $ defaultContent = null ;
63
-
64
- if (null !== $ defaultTemplate ) {
65
- if ($ this ->templateExists ($ defaultTemplate )) {
66
- $ defaultContent = $ this ->templating ->render ($ defaultContent );
67
- } else {
68
- $ defaultContent = $ defaultTemplate ;
69
- }
70
- } elseif ($ this ->globalDefaultTemplate ) {
71
- $ defaultContent = $ this ->templating ->render ($ this ->globalDefaultTemplate );
65
+ $ template = isset ($ options ['default ' ]) ? $ options ['default ' ] : $ this ->globalDefaultTemplate ;
66
+ if ($ this ->templateExists ($ template )) {
67
+ $ content = $ this ->templating ->render ($ template );
68
+ } else {
69
+ $ content = $ template ;
72
70
}
73
71
74
- return $ this ->renderHIncludeTag ($ uri , $ defaultContent );
75
- }
76
-
77
- /**
78
- * Renders an HInclude tag.
79
- *
80
- * @param string $uri A URI
81
- * @param string $defaultContent Default content
82
- */
83
- protected function renderHIncludeTag ($ uri , $ defaultContent = null )
84
- {
85
- return sprintf ('<hx:include src="%s">%s</hx:include> ' , $ uri , $ defaultContent );
72
+ return sprintf ('<hx:include src="%s">%s</hx:include> ' , $ uri , $ content );
86
73
}
87
74
88
75
private function templateExists ($ template )
0 commit comments