mirror of
				https://github.com/Mibew/handlebars.php.git
				synced 2025-11-04 04:05:07 +03:00 
			
		
		
		
	Added testHelperSubexpressions()
This commit is contained in:
		
							parent
							
								
									4bc443e834
								
							
						
					
					
						commit
						41722af86d
					
				@ -317,49 +317,6 @@ class Template
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Process handlebars subexpression
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param Context $context current context
 | 
					 | 
				
			||||||
     * @param array   $current section node data
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return mixed|string
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function _handlebarsSubexpression(Context $context, $current)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $helpers = $this->handlebars->getHelpers();
 | 
					 | 
				
			||||||
        $sectionName = $current[Tokenizer::NAME];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (isset($current[Tokenizer::END])) {
 | 
					 | 
				
			||||||
            $source = substr(
 | 
					 | 
				
			||||||
                $this->getSource(),
 | 
					 | 
				
			||||||
                $current[Tokenizer::INDEX],
 | 
					 | 
				
			||||||
                $current[Tokenizer::END] - $current[Tokenizer::INDEX]
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            $source = '';
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $params = array(
 | 
					 | 
				
			||||||
            $this, //First argument is this template
 | 
					 | 
				
			||||||
            $context, //Second is current context
 | 
					 | 
				
			||||||
            $current[Tokenizer::ARGS], //Arguments
 | 
					 | 
				
			||||||
            $source
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//         echo "Context: ",  "\n";
 | 
					 | 
				
			||||||
//         print_r( $params[1] );
 | 
					 | 
				
			||||||
        echo "arguments: ", $params[2], "\n";
 | 
					 | 
				
			||||||
        echo "src: ", $params[3], "\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $return = call_user_func_array($helpers->$sectionName, $params);
 | 
					 | 
				
			||||||
        echo "result: ", $return, "\n\n";
 | 
					 | 
				
			||||||
        if ($return instanceof String) {
 | 
					 | 
				
			||||||
            return $return;
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            return $return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Process Mustache section style
 | 
					     * Process Mustache section style
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user