@param Compiler $compiler
@param array    $params
@param string   $prepend
@param string   $append
@param string   $content

@return string
502708
public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
    {
        $params = $compiler->getCompiledParams($params);
        $tpl    = $compiler->getTemplateSource($params['tplPointer']);

        // assigns params
        $src  = $params['from'];
        $name = $params['name'];

        // evaluates which global variables have to be computed
        $varName       = '$dwoo.loop.' . trim($name, '"\'') . '.';
        $shortVarName  = '$.loop.' . trim($name, '"\'') . '.';
        $usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
        $usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
        $usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
        $usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
        $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
        $usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
        $usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;

        if (strpos($name, '$this->scope[') !== false) {
            $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
        }

        // gets foreach id
        $cnt = self::$cnt ++;

        // builds pre processing output
        $pre = Compiler::PHP_OPEN . "\n" . '$_loop' . $cnt . '_data = ' . $src . ';';
        // adds foreach properties
        if ($usesAny) {
            $pre .= "\n" . '$this->globals["loop"][' . $name . '] = array' . "\n(";
            if ($usesIndex) {
                $pre .= "\n\t" . '"index"		=> 0,';
            }
            if ($usesIteration) {
                $pre .= "\n\t" . '"iteration"		=> 1,';
            }
            if ($usesFirst) {
                $pre .= "\n\t" . '"first"		=> null,';
            }
            if ($usesLast) {
                $pre .= "\n\t" . '"last"		=> null,';
            }
            if ($usesShow) {
                $pre .= "\n\t" . '"show"		=> $this->isTraversable($_loop' . $cnt . '_data, true),';
            }
            if ($usesTotal) {
                $pre .= "\n\t" . '"total"		=> $this->count($_loop' . $cnt . '_data),';
            }
            $pre .= "\n);\n" . '$_loop' . $cnt . '_glob =& $this->globals["loop"][' . $name . '];';
        }
        // checks if the loop must be looped
        $pre .= "\n" . 'if ($this->isTraversable($_loop' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
        // iterates over keys
        $pre .= "\n\t" . 'foreach ($_loop' . $cnt . '_data as $tmp_key => $this->scope["-loop-"])' . "\n\t{";
        // updates properties
        if ($usesFirst) {
            $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["first"] = (string) ($_loop' . $cnt . '_glob["index"] === 0);';
        }
        if ($usesLast) {
            $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["last"] = (string) ($_loop' . $cnt . '_glob["iteration"] === $_loop' . $cnt . '_glob["total"]);';
        }
        $pre .= "\n\t\t" . '$_loop' . $cnt . '_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n" . Compiler::PHP_CLOSE;

        // build post processing output and cache it
        $post = Compiler::PHP_OPEN . "\n" . '/* -- loop end output */' . "\n\t\t" . '$this->setScope($_loop' . $cnt . '_scope, true);';
        // update properties
        if ($usesIndex) {
            $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["index"]+=1;';
        }
        if ($usesIteration) {
            $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["iteration"]+=1;';
        }
        // end loop
        $post .= "\n\t}\n}\n" . Compiler::PHP_CLOSE;
        if (isset($params['hasElse'])) {
            $post .= $params['hasElse'];
        }

        return $pre . $content . $post;
    }
794659
public static function prepend(string $filename, string $content): int
    {
        if (self::exist($filename)) {
            return self::put($filename, $content . self::get($filename));
        }
        return self::put($filename, $content);
    }
705693
function append(compiler, value, node) {
  if (typeof compiler.append !== 'function') {
    return compiler.emit(value, node);
  }
  return compiler.append(value, node);
}
888256
public void appendTo(
      Appendable out,
      DependencyInfo info,
      CharSource content) throws IOException {
    if (info.isModule()) {
      mode.appendGoogModule(transpile(content.read()), out, sourceUrl);
    } else if ("es6".equals(info.getLoadFlags().get("module")) && transpiler == Transpiler.NULL) {
      // TODO(johnplaisted): Make the default transpiler the ES_MODULE_TO_CJS_TRANSPILER. Currently
      // some code is passing in unicode identifiers in non-ES6 modules the compiler fails to parse.
      // Once this compiler bug is fixed we can always transpile.
      mode.appendTraditional(transpileEs6Module(content.read()), out, sourceUrl);
    } else {
      mode.appendTraditional(transpile(content.read()), out, sourceUrl);
    }
  }
1283281
public function prependScript($script, $type = 'text/javascript', array $params = [], $conditional = '')
    {
        return $this->setScript($script, $type, $params, true, $conditional);
    }
1277604
public function compile(\Twig_Compiler $compiler) {
		$compiler->addDebugInfo($this);

		list($msg, $vars) = $this->compileString($this->getNode('body'));

		if (null !== $this->getNode('plural')) {
			list($msg1, $vars1) = $this->compileString($this->getNode('plural'));

			$vars = array_merge($vars, $vars1);
		}

		$function = null === $this->getNode('plural') ? 'Translation::translate' : 'Translation::translate_plural';

		if ($vars) {
			$compiler
				->write('echo strtr('.$function.'(')
				->subcompile($msg)
			;

			if (null !== $this->getNode('plural')) {
				$compiler
					->raw(', ')
					->subcompile($msg1)
					->raw(', abs(')
					->subcompile($this->getNode('count'))
					->raw(')')
				;
			}

			$compiler->raw(', $context[\'env\'][\'translation\']), array(');

			foreach ($vars as $var) {
				if ('count' === $var->getAttribute('name')) {
					$compiler
						->string('%count%')
						->raw(' => abs(')
						->subcompile($this->getNode('count'))
						->raw('), ')
					;
				} else {
					$compiler
						->string('%'.$var->getAttribute('name').'%')
						->raw(' => ')
						->subcompile($var)
						->raw(', ')
					;
				}
			}

			$compiler->raw("));\n");
		} else {
			$compiler
				->write('echo '.$function.'(')
				->subcompile($msg)
			;

			if (null !== $this->getNode('plural')) {
				$compiler
					->raw(', ')
					->subcompile($msg1)
					->raw(', abs(')
					->subcompile($this->getNode('count'))
					->raw(')')
				;
			}

			$compiler->raw(", " . '$context[\'env\'][\'translation\']' . ");\n");
		}
	}
7846
public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
    {
        $with = &$compiler->findBlock('for', true);

        $params['initialized'] = true;
        $compiler->injectBlock($type, $params);

        return '';
    }
989516
public function prepend($content, $selector = null)
    {
        if (is_array($content)) {
            $content = join("\n", $content);
        }

        return $this->cmd('prepend', array(
            $this->typecast($content, true, true)
        ), $selector);
    }
808440
public function injectTemplateContent($content, $params)
    {
        return str_replace(
            array(
                '%__ERROR_TYPE__%',
                '%__ERROR_REFERENCE__%',
                '%__ERROR_MESSAGE__%',
                '%__ERROR_FILE__%',
                '%__ERROR_LINE__%'
            ),
            array_map('addslashes',array(
                $params['type'],
                $params['reference'],
                $params['message'],
                $params['file'],
                $params['line']
            )),
            $content
        );
    }
367442
public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
    {
        try {
            $compiler->findBlock('dynamic');

            return $content;
        }
        catch (CompilationException $e) {
        }
        $output = Compiler::PHP_OPEN . 'if($doCache) {' . "\n\t" . 'echo \'<dwoo:dynamic_\'.$dynamicId.\'>' . str_replace('\'', '\\\'', $content) . '</dwoo:dynamic_\'.$dynamicId.\'>\';' . "\n} else {\n\t";
        if (substr($content, 0, strlen(Compiler::PHP_OPEN)) == Compiler::PHP_OPEN) {
            $output .= substr($content, strlen(Compiler::PHP_OPEN));
        } else {
            $output .= Compiler::PHP_CLOSE . $content;
        }
        if (substr($output, - strlen(Compiler::PHP_CLOSE)) == Compiler::PHP_CLOSE) {
            $output = substr($output, 0, - strlen(Compiler::PHP_CLOSE));
        } else {
            $output .= Compiler::PHP_OPEN;
        }
        $output .= "\n}" . Compiler::PHP_CLOSE;

        return $output;
    }
1190338
public function addAsyncJsUrl(string $src, bool $prepend = false) {
		$this->htmlProperties->add(self::HEAD_SCRIPT_KEY, 'type:javascript:src:' . $src,
				new HtmlElement('script', array(/*'type' => 'text/javascript'*/),
						"\r\n" . '//<![CDATA[' . "\r\n" . '(function() {var b=document.createElement("script");b.type="text/javascript";b.async=true;b.src="' .
						addslashes($src) . '";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(b,a)})();' . "\r\n" . '//]]>' . "\r\n"),
				$prepend);
		
		return $this;
	}
416844
public function compile(Twig_Compiler $compiler)
    {
        $hasBody = $this->hasNode('default');
        $varId = '__placeholder_'.$this->getAttribute('name').'_default_contents';
        $compiler
            ->addDebugInfo($this)
            ->write("\$context[")
            ->raw("'".$varId."'")
            ->raw("] = null;");

        if ($hasBody) {
            $compiler
                ->addDebugInfo($this)
                ->write('ob_start();')
                ->subcompile($this->getNode('default'))
                ->write("\$context[")
                ->raw("'".$varId."'")
                ->raw("] = ob_get_clean();");
        }

        $isText = $this->hasAttribute('type') && $this->getAttribute('type') == 'text';

        $compiler->addDebugInfo($this);
        if (!$isText) {
            $compiler->write("echo \$this->env->getExtension('Cms\Twig\Extension')->displayBlock(");
        }
        else {
            $compiler->write("echo twig_escape_filter(\$this->env, \$this->env->getExtension('Cms\Twig\Extension')->displayBlock(");
        }

        $compiler
            ->raw("'".$this->getAttribute('name')."', ")
            ->raw("\$context[")
            ->raw("'".$varId."'")
            ->raw("]")
            ->raw(")");

        if (!$isText) {
            $compiler->raw(";\n");
        }
        else {
            $compiler->raw(");\n");
        }

        $compiler
            ->addDebugInfo($this)
            ->write("unset(\$context[")
            ->raw("'".$varId."'")
            ->raw("]);");
    }
608432
private function compileComplex(Compiler $compiler): void
    {
        $prefix  = $this->getAttribute('prefix');
        $postfix = $this->getAttribute('postfix');
        $lines   = $this->getNode('lines');

        // We use normal subcompilation, which uses echo so we buffer our output.
        $compiler->write("ob_start();\n");
        $compiler->subcompile($lines);

        $ltrim_prefix = ltrim($prefix);                        // Trimmed version for use on first line
        $indent       = ! trim($prefix) && ! trim($postfix);   // Are we only indenting or also prefixing

        // Fetch the content of the lines inside of this block
        // and itterate over them
        $compiler
            ->write("\$lines = explode(\"\\n\", ob_get_clean());\n")
            ->write("foreach (\$lines as \$key => \$line) {\n")
            ->indent(1);

        // If we are indenting code we have the risk of generating empty lines, so check for this.
        if ($indent) {
            $compiler
                ->write("if (trim(\$line)) {\n")
                ->indent(1);
        }

        // Write out the prefix for this line.
        if ($prefix) {
            $compiler->write("echo \$key > 0 ? '$prefix' : '$ltrim_prefix' ;\n");
        }

        // Write the line itself
        $compiler->write("echo \"\$line\";\n");

        // Close if statement for empty line check when indenting.
        if ($indent) {
            $compiler
                ->outdent(1)
                ->write("}\n");
        }

        // Write postfix and new line.
        $compiler
            ->write("echo \"$postfix\\n\";\n")
            ->outdent(1)
            ->write("}\n");
    }
935498
public function addScript ($src, $prepend = false)
		{
			if ($prepend) {
				array_unshift($this->scriptUrls, $src);
			} else {
				$this->scriptUrls[] = $src;
			}

			$html = '<script type="text/javascript" src="' . $this->sanitize($src) . '"></script>';

			$this->addHeader($html, $prepend);
		}
1045149
public function compile($args, $compiler)
    {
        $compiler->has_code = true;
        // check and get attributes
        $_attr = $this->getAttributes($compiler, $args);
        $saved_data = $this->closeTag($compiler, array('block'));
        $_name = trim($saved_data[0]['name'], "\"'");
        if (isset($compiler->template->block_data[$_name]) && !isset($compiler->template->block_data[$_name]['compiled'])) {
            $_output = Smarty_Internal_Compile_Block::compileChildBlock($compiler, $_name);
        } else {
            if (isset($saved_data[0]['hide']) && !isset($compiler->template->block_data[$_name]['source'])) {
                $_output = '';
            } else {
                $_output = $compiler->parser->current_buffer->to_smarty_php();
            }
            unset ($compiler->template->block_data[$_name]['compiled']);
        }
        // reset flags
        $compiler->parser->current_buffer = $saved_data[1];
        $compiler->nocache = $saved_data[2];
        $compiler->smarty->merge_compiled_includes = $saved_data[3];
        // reset flag for {block} tag
        $compiler->inheritance = false;
        // $_output content has already nocache code processed
        $compiler->suppressNocacheProcessing = true;
        return $_output;
    }
960886
protected function generateCallCode($typeName, \ReflectionFunction $ref, $num, array $prepend = [], array $resolvers = NULL)
	{
		$code = '$this->call_' . $num . '(';
		
		foreach($ref->getParameters() as $i => $param)
		{
			if($i != 0)
			{
				$code .= ', ';
			}
			
			if(array_key_exists($i, $prepend))
			{
				$code .= $prepend[$i];
				
				continue;
			}
			
			if($resolvers !== NULL && array_key_exists($param->name, $resolvers))
			{
				$resolver = $resolvers[$param->name];
				
				if($resolver instanceof \Closure)
				{
					$num = count($this->methods);
						
					$ref = new \ReflectionFunction($resolver);
					$sig = $this->generateReplacementMethodSignature($ref, $num);
					$body = $this->extractClosureCode($ref);
					
					$this->methods[] = "\t\t" . $sig . " {\n" . $body . "\n\t\t}";
					
					$code .= $this->generateCallCode($typeName, $ref, $num);
					
					continue;
				}
				elseif($resolver instanceof CompiledCodeFragment)
				{
					$code .= $resolver;
					
					continue;
				}
				
				$code .= var_export($resolver, true);
				
				continue;
			}
			
			if(NULL !== ($ptype = $this->getParamType($param)))
			{
				if($ptype === InjectionPointInterface::class)
				{
					$code .= '$point';
					
					continue;
				}
				
				$code .= '$this->get(' . var_export($ptype, true) . ', isset($point) ? $point : NULL)';
				
				continue;
			}
			
			if($param->isOptional())
			{
				$code .= $param->isDefaultValueAvailable() ? var_export($param->getDefaultValue(), true) : 'NULL';
				
				continue;
			}
			
			throw new TypeNotFoundException(sprintf('Cannot populate closure param "%s" without type hint or resolver', $param->name));
		}
		
		return $code . ')';
	}
22136
public static function compile(Compiler $compiler, $value, $addspace = true, $allowable_tags = null)
    {
        if ($addspace === 'true') {
            if ("null" == $allowable_tags) {
                return "preg_replace('#<[^>]*>#', ' ', $value)";
            }

            return "preg_replace('#<\\s*\\/?(" . $allowable_tags . ")\\s*[^>]*?>#im', ' ', $value)";
        }

        return "strip_tags($value, $allowable_tags)";
    }