. */ /** * Template partials tags. * * @since 4.6.0 */ namespace Textpattern\Tag\Syntax; class Partial { /** * Returns the inner content of the enclosing <txp:output_form /> tag. * * @param array $atts * @param string $thing * @return string */ public static function renderYield($atts, $thing = null) { global $yield, $txp_yield, $txp_atts, $txp_item; extract(lAtts(array( 'name' => '', 'else' => false, 'default' => false, 'item' => null ), $atts)); if (isset($item)) { $inner = isset($txp_item[$item]) ? $txp_item[$item] : null; } elseif ($name === '') { $end = empty($yield) ? null : end($yield); if (isset($end)) { $inner = parse($end, empty($else)); } } elseif (!empty($txp_yield[$name])) { list($inner) = end($txp_yield[$name]); $txp_yield[$name][key($txp_yield[$name])][1] = true; } if (!isset($inner)) { $escape = isset($txp_atts['escape']) ? $txp_atts['escape'] : null; $inner = $default !== false ? ($default === true ? page_url(array('type' => $name, 'escape' => $escape)) : $default) : ($thing ? parse($thing) : $thing); } return $inner; } /** * Conditional for yield. * * @param array $atts * @param string $thing * @return string */ public static function renderIfYield($atts, $thing = null) { global $yield, $txp_yield, $txp_item; extract(lAtts(array( 'name' => '', 'else' => false, 'value' => null, 'item' => null ), $atts)); if (isset($item)) { $inner = isset($txp_item[$item]) ? $txp_item[$item] : null; } elseif ($name === '') { $end = empty($yield) ? null : end($yield); if (isset($end)) { $inner = $value === null ? ($else ? getIfElse($end, false) : true) : parse($end, empty($else)); } } elseif (empty($txp_yield[$name])) { $inner = null; } else { list($inner) = end($txp_yield[$name]); } return parse($thing, isset($inner) && ($value === null || (string)$inner === (string)$value || $inner && $value === true)); } }