當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhpWriter::formatArgs方法代碼示例

本文整理匯總了PHP中Latte\PhpWriter::formatArgs方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhpWriter::formatArgs方法的具體用法?PHP PhpWriter::formatArgs怎麽用?PHP PhpWriter::formatArgs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Latte\PhpWriter的用法示例。


在下文中一共展示了PhpWriter::formatArgs方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: macroEachEnd

 public function macroEachEnd(MacroNode $node, PhpWriter $writer)
 {
     if ($node->modifiers && $node->modifiers !== '|noiterator') {
         trigger_error('Only modifier |noiterator is allowed here.', E_USER_WARNING);
     }
     $args = $writer->formatArgs();
     if (substr($args, 0, 3) === 'as ') {
         $parts = [self::$defaultEachArrayName, substr($args, 3)];
     } elseif (empty($args)) {
         $parts = [self::$defaultEachArrayName];
     } else {
         $parts = Strings::split($args, '#\\s+as\\s+#i');
     }
     if (count($parts) === 1) {
         $parts[] = '$' . self::$defaultEachVarName;
     }
     $array = $parts[0];
     $parts[0] = '(($_l_q instanceof WP_Query)?$_l_q->get_posts():(array)$_l_q)';
     $args = implode(' as ', $parts);
     if ($node->modifiers !== '|noiterator' && preg_match('#\\W(\\$iterator|include|require|get_defined_vars)\\W#', $this->getCompiler()->expandTokens($node->content))) {
         $node->openingCode = '<?php $iterations = 0; $_l_q=' . $array . '; foreach ($iterator = $_l->its[] = new Latte\\Runtime\\CachingIterator(' . preg_replace('#(.*)\\s+as\\s+#i', '$1) as ', $args, 1) . ') { ?>';
         $node->closingCode = '<?php $iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?>';
     } else {
         $node->openingCode = '<?php $iterations = 0; $_l_q=' . $array . '; foreach (' . $args . ') { ?>';
         $node->closingCode = '<?php $iterations++; } ?>';
     }
 }
開發者ID:manGoweb,項目名稱:MangoPressTemplating,代碼行數:27,代碼來源:MangoPressTemplatingMacroSet.php

示例2: macroImgLink

    /**
     * {imgLink $img [type]}
     * @param Latte\MacroNode $node
     * @param Latte\PhpWriter $writer
     * @return string
     */
    public function macroImgLink(Latte\MacroNode $node, Latte\PhpWriter $writer)
    {
        list($img, $type) = $this->getImageFromNode($node);
        return '
			$args = [' . ($type ? "'type' => '{$type}', " : NULL) . "'storage' => " . '$imageStorage' . ($node->args ? ', ' . $writer->formatArgs() : NULL) . '];
			echo ' . get_class($this) . '::imgLink(' . $img . ', $args);
		';
    }
開發者ID:harmim,項目名稱:images,代碼行數:14,代碼來源:Macros.php

示例3: macroControl

 /**
  * {control name[:method] [params]}
  */
 public function macroControl(MacroNode $node, PhpWriter $writer)
 {
     $words = $node->tokenizer->fetchWords();
     if (!$words) {
         throw new CompileException('Missing control name in {control}');
     }
     $name = $writer->formatWord($words[0]);
     $method = isset($words[1]) ? ucfirst($words[1]) : '';
     $method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
     $param = $writer->formatArgs();
     if (Strings::contains($node->args, '=>')) {
         $param = "[{$param}]";
     }
     return ($name[0] === '$' ? "if (is_object({$name})) \$_l->tmp = {$name}; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' . 'if ($_l->tmp instanceof Nette\\Application\\UI\\IRenderable) $_l->tmp->redrawControl(NULL, FALSE); ' . ($node->modifiers === '' ? "\$_l->tmp->{$method}({$param})" : $writer->write("ob_start(); \$_l->tmp->{$method}({$param}); echo %modify(ob_get_clean())"));
 }
開發者ID:TomasVotruba,項目名稱:application,代碼行數:18,代碼來源:UIMacros.php

示例4: macroDump

 /**
  * {dump ...}
  */
 public function macroDump(MacroNode $node, PhpWriter $writer)
 {
     if ($node->modifiers) {
         trigger_error("Modifiers are not allowed in {{$node->name}}", E_USER_WARNING);
     }
     $args = $writer->formatArgs();
     return $writer->write('Tracy\\Debugger::barDump(' . ($args ? "({$args})" : 'get_defined_vars()') . ', %var)', $args ?: 'variables');
 }
開發者ID:luminousinfoways,項目名稱:pccfoas,代碼行數:11,代碼來源:CoreMacros.php

示例5: macroDump

 /**
  * {dump ...}
  */
 public function macroDump(MacroNode $node, PhpWriter $writer)
 {
     if ($node->modifiers) {
         throw new CompileException("Modifiers are not allowed in {{$node->name}}");
     }
     $args = $writer->formatArgs();
     return $writer->write('Tracy\\Debugger::barDump(' . ($args ? "({$args})" : 'get_defined_vars()') . ', %var)', $args ?: 'variables');
 }
開發者ID:richard-ejem,項目名稱:latte,代碼行數:11,代碼來源:CoreMacros.php

示例6: macroIfset

 /**
  * {ifset #block}
  * {elseifset #block}
  */
 public function macroIfset(MacroNode $node, PhpWriter $writer)
 {
     if ($node->modifiers) {
         trigger_error("Modifiers are not allowed in {{$node->name}}", E_USER_WARNING);
     }
     if (!preg_match('~#|[\\w-]+\\z~A', $node->args)) {
         return FALSE;
     }
     $list = array();
     while (($name = $node->tokenizer->fetchWord()) !== FALSE) {
         $list[] = preg_match('~#|[\\w-]+\\z~A', $name) ? '$_b->blocks["' . ltrim($name, '#') . '"]' : $writer->formatArgs(new Latte\MacroTokens($name));
     }
     return ($node->name === 'elseifset' ? '} else' : '') . 'if (isset(' . implode(', ', $list) . ')) {';
 }
開發者ID:knedle,項目名稱:twitter-nette-skeleton,代碼行數:18,代碼來源:BlockMacros.php

示例7: macroDump

 /**
  * {dump ...}
  */
 public function macroDump(MacroNode $node, PhpWriter $writer)
 {
     $args = $writer->formatArgs();
     return 'Tracy\\Debugger::barDump(' . ($node->args ? $writer->write("array(%var => {$args})", $args) : 'get_defined_vars()') . ', "Template " . str_replace(dirname(dirname($template->getName())), "\\xE2\\x80\\xA6", $template->getName()))';
 }
開發者ID:petrparolek,項目名稱:web_cms,代碼行數:8,代碼來源:CoreMacros.php

示例8: createIterator

 /**
  * @from https://github.com/nette/latte/blob/master/src/Latte/Macros/CoreMacros.php#L253-L263
  *
  * @param \Latte\MacroNode $node
  * @param \Latte\PhpWriter $writer
  * @param string $iterate
  */
 private function createIterator(MacroNode $node, PhpWriter $writer, $iterate)
 {
     if ($node->modifiers !== '|noiterator' && preg_match('#\\W(\\$iterator|include|require|get_defined_vars)\\W#', $this->getCompiler()->expandTokens($node->content))) {
         $node->openingCode = '<?php $iterations = 0; foreach ($iterator = $_l->its[] = new Latte\\Runtime\\CachingIterator(' . $iterate . ') as ' . $writer->formatArgs() . ') { ?>';
         $node->closingCode = '<?php $iterations++; } array_pop($_l->its); $iterator = end($_l->its) ?>';
     } else {
         $node->openingCode = '<?php $iterations = 0; foreach (' . $iterate . ' as ' . $writer->formatArgs() . ') { ?>';
         $node->closingCode = '<?php $iterations++; } ?>';
     }
 }
開發者ID:wodCZ,項目名稱:Nette-NoGrid,代碼行數:17,代碼來源:Macros.php

示例9: macroIfset

 /**
  * {ifset #block}
  * {elseifset #block}
  */
 public function macroIfset(MacroNode $node, PhpWriter $writer)
 {
     if ($node->modifiers) {
         throw new CompileException('Modifiers are not allowed here.');
     }
     if (!preg_match('~#|[\\w-]+\\z~A', $node->args)) {
         return FALSE;
     }
     $list = [];
     while (($name = $node->tokenizer->fetchWord()) !== FALSE) {
         $list[] = preg_match('~#|[\\w-]+\\z~A', $name) ? '$_b->blocks["' . ltrim($name, '#') . '"]' : $writer->formatArgs(new Latte\MacroTokens($name));
     }
     return ($node->name === 'elseifset' ? '} else' : '') . 'if (isset(' . implode(', ', $list) . ')) {';
 }
開發者ID:JoeHorn,項目名稱:latte,代碼行數:18,代碼來源:BlockMacros.php

示例10: macroDump

 /**
  * {dump ...}
  */
 public function macroDump(MacroNode $node, PhpWriter $writer)
 {
     $args = $writer->formatArgs();
     return $writer->write('Tracy\\Debugger::barDump(' . ($args ? "({$args})" : 'get_defined_vars()') . ', %var)', $args ?: 'variables');
 }
開發者ID:jave007,項目名稱:test,代碼行數:8,代碼來源:CoreMacros.php


注:本文中的Latte\PhpWriter::formatArgs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。