Parsing content for loop varliable
@access private
@param string $variable loop name
@param string $value loop data
@param string $string content to replace
@return string replaced content
509370
private function parsePair( $variable, $data, $string )
    {
        $match = $this->matchPair($string, $variable);
        if( $match == false ) return $string;

        $str = '';
        foreach ( $data as $k_row => $row ) {
            $temp = $match['1'];
            foreach( $row as $key => $val ) {
                if( !is_array( $val ) ) {
                    $index = array_search( $k_row, array_keys( $data ) );
                    $temp = $this->parseSingle( $key, $val, $temp, $index );
                } else {
                    $temp = $this->parsePair( $key, $val, $temp );
                }
            }
            $str .= $temp;
        }

        return str_replace( $match['0'], $str, $string );
    }
705876
private function parseString(&$var, BasicObject $o)
    {
        $string = new BlobObject();
        $string->transplant($o);
        $string->encoding = BlobObject::detectEncoding($var);
        $string->size = BlobObject::strlen($var, $string->encoding);

        $rep = new Representation('Contents');
        $rep->contents = $var;
        $rep->implicit_label = true;

        $string->addRepresentation($rep);
        $string->value = $rep;

        $this->applyPlugins($var, $string, self::TRIGGER_SUCCESS);

        return $string;
    }
952106
public function setVariable($key, $value) {
        $this->_content = str_replace('#' . $key . '#', (string)$value, $this->_content);
        return $this;
    }
1041779
public function assignString(Variable $variable, $value, CompilationContext $context, $useCodePrinter = true, $doCopy = null)
    {
        return $this->assignHelper('ZVAL_STRING', $this->getVariableCode($variable), $value, $context, $useCodePrinter, null);
    }
470624
protected function replaceContent($content, $vars = [])
    {
        $find = [];
        $replace =[];
        foreach($vars as $k => $v) {
            $find[] = '#' . $k . '#';
            $replace[] = $v;
        }
        return str_ireplace($find, $replace, $content);
    }
521186
protected function replace($value)
    {
        if ('env' === substr($value, 0, 3)) {
            $env = substr($value, 4);

            return env($env);
        }

        if (empty($value) || false === strpos($value, '%')) {
            return $value;
        }

        return $this->variable($value);
    }
958620
public static String substituteVariables(String value) {
        Matcher matcher = varPattern.matcher(value);
        boolean found = matcher.find();
        if (!found) {
            return value;
        }
        StringBuffer sb = new StringBuffer();
        do {
            String sysPropKey = matcher.group(1);
            String sysPropValue = getSystemVariableValue(sysPropKey, null);
            if (sysPropValue == null || sysPropValue.length() == 0) {
                throw new RuntimeException("System property " + sysPropKey + " is not specified");
            }
            // Due to reported bug under CARBON-14746
            sysPropValue = sysPropValue.replace("\\", "\\\\");
            matcher.appendReplacement(sb, sysPropValue);
        } while (matcher.find());
        matcher.appendTail(sb);
        return sb.toString();
    }
363002
public function setVariable($variable, $value)
    {
        return $this->client->channels()->setVariable($this->id, $variable, $value);
    }
180615
public static function toPHPVariableString($value)
    {
		switch (gettype($value)) {
        	case "string" :
        	    $returnValue = '\''.str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value)).'\'';
        		break;
        	case "boolean" :
        		$returnValue = $value ? 'true' : 'false';
        		break;
        	case "integer" :
        	case "double" :
        		$returnValue = $value;
        		break;
        	case "array" :
				$string = "";
				foreach ($value as $key => $val) {
					$string .= self::toPHPVariableString($key)." => ".self::toPHPVariableString($val).",";
				}
				$returnValue = "array(".substr($string, 0, -1).")";
				break;
        	case "NULL" :
        		$returnValue = 'null';
				break;
        	case "object" :
        	    if ($value instanceof PhpSerializable) {
        	       $returnValue = $value->__toPhpCode();
        	    } else {
        	       $returnValue =  'unserialize('.self::toPHPVariableString(serialize($value)).')';
        	    }
        		break;
        	default:
    			// resource and unexpected types
        		throw new common_exception_Error("Could not convert variable of type ".gettype($value)." to PHP variable string");
        }

        return (string) $returnValue;
    }
679080
function variableText( $var, $namespace = "", $attrs = array() )
    {
        $txt = "$";
        if ( $namespace != "" )
            $txt .= "$namespace:";
        $txt .= $var;
        if ( !empty( $attrs ) )
            $txt .= "." . implode( ".", $attrs );
        return $txt;
    }
104444
public static function parse($value)
    {
        $expression = Expression::getExpression();

        $return = preg_match(
            $expression,
            $value,
            $matches
        );

        if (!$return) {
            return null;
        }

        $parsed = new \stdClass();

        $parsed->key = $matches['key'];
        $parsed->mode = Globals::KEY_VARIABLE;

        if (isset($matches['function']) && !empty($matches['function'])) {
            $parsed->mode = Globals::KEY_FUNCTION;

            if (key_exists('parameters', $matches)  && strlen((string)$matches['parameters'])) {
                //Handles only one parameter
                $parsed->parameters = [$matches['parameters']];
            }
        } elseif (isset($matches['array'])  && !empty($matches['array'])) {
            $parsed->mode = Globals::KEY_ARRAY;
            //should exists
            $parsed->index = $matches['index'];
        }

        return $parsed;
    }
194982
private function matchPair( $string, $variable )
    {
        if ( !preg_match("|" . preg_quote($this->l_delim) . 'loop ' . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . 'end loop' . preg_quote($this->r_delim) . "|s", $string, $match ) ) {
            return false;
        }

        return $match;
    }
873661
protected function formatEnvironmentVariableValue($value)
    {
        if (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = $this->formatEnvironmentVariableValue($v);
            }
            $value = join(' ', $value);
        } elseif (is_object($value)) {
            $value = json_encode($value);
        }

        return str_replace('"', '\"', $value);
    }
248678
protected function replaceVariables($string)
    {
        do {
            $original = $string;

            $string = $this->searchAndReplaceVariables($string);
        } while ($original !== $string);

        return $string;
    }
1223600
public static function variable($string)
    {
        if (!($result = self::_cache(__FUNCTION__, $string))) {
            $camelized = Inflector::camelize(Inflector::underscore($string));
            $replace = strtolower(substr($camelized, 0, 1));
            $result = preg_replace('/\\w/', $replace, $camelized, 1);
            self::_cache(__FUNCTION__, $string, $result);
        }
        return $result;
    }
146531
private function _printVar($var)
    {
        if (is_string($var)) {
            $search = array("\x00", "\x0a", "\x0d", "\x1a", "\x09");
            $replace = array('\0', '\n', '\r', '\Z', '\t');

            return ('"'.str_replace($search, $replace, $var).'"');
        } elseif (is_bool($var)) {
            if ($var) {
                return ('true');
            } else {
                return ('false');
            }
        } elseif (is_array($var)) {
            $strResult = 'array( ';
            $strComma = '';
            foreach ($var as $key=>$val) {
                $strResult .= $strComma.$this->_printVar($key).' => '.$this->_printVar($val);
                $strComma = ', ';
            }
            $strResult .= ' )';

            return ($strResult);
        }
        // anything else, just let php try to print it
        return (var_export($var, true));
    }
494606
function (loop, variables) {
    var variable = false;
    try {
        variable = varsParser.evaluate('(' + loop.variable + ')', variables);
    } catch (err) {
        throw new Error('Error executing loop expression: ' + loop.variable + ' <' + err.message + '>');
    }

    var html = '';
    var loopVariables = _.clone(variables, true);

    (function (iterate) {
        if (Array.isArray(variable)) {
            for (var i = 0, l = variable.length; i < l; i++) {
                iterate(i, variable[i]);
            }
        } else {
            for (var i in variable) {
                if (!variable.hasOwnProperty(i)) {
                    continue;
                }
                iterate(i, variable[i]);
            }
        }
    })(function (key, value) {
        loopVariables.$key = loopVariables[loop.keyName] = key;
        loopVariables.$value = loopVariables[loop.valueName] = value;

        var loopHtml = loop.content;

         //<if/> (condicionais, execução das condicionais para geração do template)
        loopHtml = conditionalParser(loopHtml, loopVariables);

        loop.children.forEach(function (child) {
            loopHtml = loopHtml.replace(child.mark, proccessLoop(child, loopVariables));
        });

        // #{vars} (escapando as variaveis no template)
        loopHtml = varsParser.escapeValues(loopHtml, loopVariables);

        html += loopHtml;
    });

    return html;
}