File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -197,13 +197,18 @@ protected function stop()
197
197
198
198
/**
199
199
* Returns the content for a section block.
200
- * @param string $name
201
- * @return null
200
+ * @param string $name Section name
201
+ * @param string $default Default section content
202
+ * @return string|null
202
203
*/
203
- protected function section ($ name )
204
+ protected function section ($ name, $ default = null )
204
205
{
205
206
if (!isset ($ this ->sections [$ name ])) {
206
207
208
+ if (null !== $ default ) {
209
+ return $ default ;
210
+ }
211
+
207
212
return null ;
208
213
}
209
214
Original file line number Diff line number Diff line change @@ -145,6 +145,15 @@ public function testStopSectionBeforeStarting()
145
145
$ this ->template ->render ();
146
146
}
147
147
148
+ public function testSectionDefaultValue ()
149
+ {
150
+ vfsStream::create (array (
151
+ 'template.php ' => '<?php echo $this->section("test", "Default value") ?> '
152
+ ));
153
+
154
+ $ this ->assertEquals ($ this ->template ->render (), 'Default value ' );
155
+ }
156
+
148
157
public function testNullSection ()
149
158
{
150
159
vfsStream::create (
You can’t perform that action at this time.
0 commit comments