mirror of
				https://github.com/Mibew/handlebars.php.git
				synced 2025-11-04 04:05:07 +03:00 
			
		
		
		
	added support for "else" in in if helper. fixes #2
XXX: could it be fixed in better way?
This commit is contained in:
		
							parent
							
								
									d99f9a7830
								
							
						
					
					
						commit
						600215d648
					
				@ -70,10 +70,15 @@ class Handlebars_Helpers
 | 
			
		||||
            'if', 
 | 
			
		||||
            function ($template, $context, $args, $source) {
 | 
			
		||||
                $tmp = $context->get($args);
 | 
			
		||||
                $parts = explode('{{else}}', $source, 2);
 | 
			
		||||
                $buffer = '';
 | 
			
		||||
                if ($tmp) {
 | 
			
		||||
                    $buffer = $template->render($context);
 | 
			
		||||
                }            
 | 
			
		||||
                    $buffer = $template->getEngine()->render($parts[0], $context);
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (isset($parts[1])) {
 | 
			
		||||
                        $buffer = $template->getEngine()->render($parts[1], $context);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                return $buffer;
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user