- Made some bugfixes regarding blocks and slots
This commit is contained in:
		
							parent
							
								
									18a0fd7fdc
								
							
						
					
					
						commit
						48ecd9f7d9
					
				| @ -24,14 +24,13 @@ class BlockToken implements ControlStructure { | ||||
|                 return <<<PHP | ||||
|                     <?php  | ||||
|                         try { | ||||
|                             extract( \$this->using ?? [], \EXTR_OVERWRITE); | ||||
|                             extract( \\$class::parseArguments(function($arguments) {}, \$inlineVariables), \EXTR_OVERWRITE); | ||||
|                          | ||||
|                             unset(\$inlineVariables); | ||||
|                         }  | ||||
|                         catch(\TypeError \$ex) { | ||||
|                          | ||||
|                             throw new \Exception( | ||||
|                             sprintf('A block awaiting arguments `%s` instead received `%s` with values `%s`', '$arguments', implode(', ', array_map('gettype', \$inlineVariables)), json_encode(\$inlineVariables)) | ||||
|                                 sprintf('A block awaiting arguments `%s` instead received `%s` with values `%s`', '$arguments', implode(', ', array_map('gettype', \$inlineVariables)), json_encode(\$inlineVariables)) | ||||
|                             ); | ||||
|                         } | ||||
|                     ?>
 | ||||
| @ -72,7 +71,7 @@ class BlockToken implements ControlStructure { | ||||
|                     } | ||||
|                      | ||||
|                     return <<<PHP | ||||
|                         <?php \$___block->slotIsSet($name) || \$___block->setSlot($name, function($definition array \$___using = []) use (\$picea) { extract(\$___using, \EXTR_SKIP); ?>
 | ||||
|                         <?php (\$___block ?? \$this)->slotIsSet($name) || \$___block->setSlot($name, function($definition array \$___using = []) use (\$picea) { extract(\$___using, \EXTR_SKIP); ?>
 | ||||
|                     PHP; | ||||
|                 } | ||||
|                      | ||||
| @ -131,6 +130,9 @@ class BlockToken implements ControlStructure { | ||||
|             elseif ( $value->isVariadic() ) { | ||||
|                 $parameters[ $value->getName() ] = []; | ||||
|             } | ||||
|             else { | ||||
|                 $parameters[ $value->getName() ] = null; | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         return $parameters; | ||||
| @ -217,7 +219,7 @@ class BlockToken implements ControlStructure { | ||||
|             public function render(object $classTemplate) : string | ||||
|             { | ||||
|                 $this->rendering = true; | ||||
|                  | ||||
| 
 | ||||
|                 return $classTemplate->picea->inlineBlock($this, $this->viewPath, ...$this->arguments); | ||||
|             } | ||||
|              | ||||
|  | ||||
| @ -53,7 +53,7 @@ class SectionToken implements ControlStructure { | ||||
|     protected function printEndSection($context) : string | ||||
|     {             | ||||
|         $section = array_pop($context->sections); | ||||
|         $build = $context->extendFrom ? "\$___class__template->sectionStack && \$___class__template->renderSection({$section['name']});" : "\$___class__template->renderSection({$section['name']});"; | ||||
|         $build = $context->extendFrom ? "!empty(\$___class__template->sectionStack) && \$___class__template->renderSection({$section['name']});" : "\$___class__template->renderSection({$section['name']});"; | ||||
|         return "<?php array_pop(\$___class__template->sectionStack); }]; $build?>"; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user