0
我有一個大問題,我不明白如何解決這個問題。 所以我有助手類:使用php創建渲染控制條的助手使用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}}
的問題是,模板不顯示的data.oUser.number
值whitch是4,但顯示了代碼data.oUser.number
沒有解釋它們。幫手工作正常,因爲如果我這樣做:
{{#ifCond 2 '==' 2}} <p>Test</p> {{/ifCond}}
這工作正常。你能幫我嗎 ? THX提前對不起我的英語