2016-07-15 2 views
0

큰 문제가 있으며 해결 방법을 모르겠다. PHP를 사용하여 렌더링 핸들 막대의 도우미 만들기

class IfCondHelper implements HelperInterface 
{ 
public function execute(Template $template, HandlebarsContent $context, $args, $source) 
{ 
    $parsed_args = $template->parseArguments($args); 

    if (count($parsed_args) != 3) { 
     throw new \InvalidArgumentException(
      '"IfCond" helper expects exactly three arguments.' 
     ); 
    } 

    switch ($context->get($parsed_args[1])) { 
     case "==": 
      return ($context->get($parsed_args[0]) == $context->get($parsed_args[2])) ? $source : false; 
      break; 
.............. 
    } 
} 

지금 내 템플릿에 내가 할 : 그래서 나는 도우미에 대한 클래스가

{{#ifCond 2 '==' 2}} {{data.oUser.number}} {{/ifCond}} 

문제는 템플릿이 4 whitch data.oUser.number의 값을 표시하지만 표시되지 않는다는 것입니다 data.oUser.number 코드는 그들을 보간합니다. 헬퍼는 정상적으로 작동하기 때문에 다음과 같이 처리 할 수 ​​있습니다.

{{#ifCond 2 '==' 2}} <p>Test</p> {{/ifCond}} 

괜찮습니다. 도와 줄수있으세요 ? 사전에 들으 미안 내 영어 내가 도우미

return ($context->get($parsed_args[0]) == $context->get($parsed_args[2])) ? $template->render($context) : false; 
에게 supplimentaire 통화 후 렌더링 할 필요가 오류를 발견

답변