当前位置: 首页>>代码示例>>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;未经允许,请勿转载。