Sha256: 659d83abb4f448a6927c61a69a5ac249163e9e4db8794baf68d938d912fdd8c5

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

<?php
/* SVN FILE: $Id: HamlHelperNode.php 117 2010-09-21 09:41:58Z chris.l.yates@gmail.com $ */
/**
 * HamlHelperNode class file.
 * @author			Chris Yates <chris.l.yates@gmail.com>
 * @copyright 	Copyright (c) 2010 PBM Web Development
 * @license			http://phamlp.googlecode.com/files/license.txt
 * @package			PHamlP
 * @subpackage	Haml.tree
 */

/**
 * HamlHelperNode class.
 * Represent a helper in the Haml source.
 * The helper is run on the output from child nodes when the node is rendered.
 * @package			PHamlP
 * @subpackage	Haml.tree
 */
class HamlHelperNode extends HamlNode {
	const MATCH = '/(.*?)(\w+)\((.+?)\)(?:\s+(.*))?$/';
	const PRE = 1;
	const NAME = 2;
	const ARGS = 3;
	const BLOCK = 4;
	
	/**
	 * @var string the helper class name
	 */
	private $class;
	/**
	 * @var string helper method name
	 */
	private $pre;
	/**
	 * @var string helper method name
	 */
	private $name;
	/**
	 * @var string helper method arguments
	 */
	private $args;

	/**
	 * HamlFilterNode constructor.
	 * Sets the filter.
	 * @param string helper class.
	 * @param string helper call.
	 * @return HamlHelperNode
	 */
	public function __construct($class, $pre, $name, $args, $parent) {
	  $this->class = $class;
	  $this->pre = $pre;
	  $this->name = $name;
	  $this->args = $args;
	  $this->parent = $parent;
	  $this->root = $parent->root;
	  $parent->children[] = $this;
	}

	/**
	* Render this node.
	* The filter is run on the content of child nodes before being returned.
	* @return string the rendered node
	*/
	public function render() {
		$children = '';
		foreach ($this->children as $child) {
			$children .= trim($child->render());
		} // foreach
		$output = '<?php '.(empty($this->pre) ? 'echo' : $this->pre)." {$this->class}::{$this->name}('$children',{$this->args}); ?>";
		return $this->debug($output);
	}
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frontsau-0.0.3 lib/Phamlp/haml/tree/HamlHelperNode.php
frontsau-0.0.2 lib/Phamlp/haml/tree/HamlHelperNode.php
frontsau-0.0.1 lib/Phamlp/haml/tree/HamlHelperNode.php