Hook a partial before rendering.

@param  mixed   $view
@param  closure $callback
@return void
970670
public function partialComposer($view, $callback, $layout = null)
    {
        if (! is_array($view)) {
            $view = array($view);
        }

        // Partial path with namespace.
        $path = $this->getThemeNamespace('partials');

        // This code support partialWithLayout.
        if (! is_null($layout)) {
            $path = $path.'.'.$layout;
        }

        $view = array_map(function($v) use ($path) {
            return $path.'.'.$v;
        }, $view);

        $this->view->composer($view, $callback);
    }
60449
public function hook($event, callable $callback, $priority = 10)
    {
        $this->app->hook($event, $callback, $priority);
    }
414653
public function tweakApplication(Closure $closure): void
    {
        $closure($this->app);

        static::$server->stash([
            'class' => static::class,
            'tweakApplication' => serialize(SerializableClosure::from($closure)),
        ]);
    }
1148178
public function runBeforeView($context = null) {
        if($this->_beforeView !== null) {
            foreach($this->_beforeView as $hookProvider) {
                $hookProvider->doBeforeView($context);
            }
        }
    }
848746
public function views(ViewCollector $view)
    {
        $view->handle('{view}', Callback::class . '::viewHtml')
             ->where('view', 'html|alerts|pager|paginator');

        $view->handle('css.{type?}', Callback::class . '::viewCss')
             ->implicit('type', 'style')
             ->where('type', 'link|style');

        $view->handle('{view}', Callback::class . '::viewOther')
             ->where('view', 'collection|script|attributes|meta');
    }
529995
public function later($time, $view, array $data, Closure $callback)
    {
        return $this->mailer->later($time, $view, $data, $callback);
    }
701401
protected function afterExtending($method, $callback)
    {
        if (empty($this->afterExtendCallbacks[$method])) {
            $this->afterExtendCallbacks[$method] = array();
        }
        $this->afterExtendCallbacks[$method][] = $callback;
    }
919736
public function resolving($abstract, Closure $callback = null)
	{
		if ($callback === null && $abstract instanceof Closure)
		{
			$this->resolvingCallback($abstract);
		}
		else
		{
			$this->resolvingCallbacks[$abstract][] = $callback;
		}
	}
217257
public function preprocess(callable $callback)
    {
        if ($callback instanceof Closure) {
            $callback = $callback->bindTo($this, get_class($this));
        }

        $this->getPreprocessor()->register($callback);
        return $this;
    }
308003
protected function resolvingCallback(Closure $callback)
    {
        $abstract = $this->getFunctionHint($callback);

        if ($abstract) {
            $this->resolvingCallbacks[$abstract][] = $callback;
        } else {
            $this->globalResolvingCallbacks[] = $callback;
        }
    }
162732
private function view(View $view): void
    {
        $this->group($view->getName(), false);
        $this->presentationModel($view->getPresentationModel(), 'presentationModel');
        $this->groupEnd();
    }
618738
public function missing(Closure $callback)
	{
		$this->error(function(NotFoundHttpException $e) use ($callback)
		{
			return call_user_func($callback, $e);
		});
	}
788096
public function view($view, $data = [])
    {
        $viewPath = self::$instance->app->findView($view);
        echo self::$instance->renderView($viewPath, $data);
    }
1297275
protected function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL) {
		if(!$this->_compiled && isset($this->_editableContent)){
			$this->wrap("",$this->_editableContent);
		}
		parent::compile_once($js,$view);
		
	}
1261210
public function render(array $tokens, $view, array $partials = null)
    {
        // Do some pre-initialization of variables used later in the routine
        $renderer = $this;
        $inLoop   = false;

        if (is_scalar($view)) {
            // Iteration over lists will sometimes involve scalars
            $inLoop = true;
        }

        if (null === $partials) {
            $partials = [];
        }

        $rendered = '';
        foreach ($tokens as $token) {
            list($type, $data) = $token;
            if ($value = $this->handlePragmas($token, $view)) {
                $rendered .= $value;
                continue;
            }
            switch ($type) {
                case Lexer::TOKEN_CONTENT:
                    $rendered .= $data;
                    break;
                case Lexer::TOKEN_VARIABLE:
                    $value = $this->getValue($data, $view);
                    if (is_scalar($value)) {
                        if ($test = $this->handlePragmas($token, $value)) {
                            $rendered .= $test;
                            break;
                        }

                        $rendered .= ('' === $value) ? '' : $this->escape($value);
                        break;
                    }

                    $pragmaView = [$data => $value];
                    if ($test = $this->handlePragmas($token, $pragmaView)) {
                        $rendered .= $test;
                        break;
                    }

                    $rendered .= (string) $value;
                    break;
                case Lexer::TOKEN_VARIABLE_RAW:
                    $value = $this->getValue($data, $view);
                    $rendered .= $value;
                    break;
                case Lexer::TOKEN_SECTION:
                    if ($inLoop) {
                        // In a loop, with scalar values; skip
                        break;
                    }
                    $section = $this->getValue($data['name'], $view);
                    if (! $section) {
                        // Section is not a true value; skip
                        break;
                    }

                    // Build the section view
                    $sectionView = $section;
                    if (is_bool($section)) {
                        // For a boolean true, pass the current view
                        $sectionView = $view;
                    }
                    if (is_array($section) || $section instanceof Traversable) {
                        if (is_array($section) && $this->isAssocArray($section)) {
                            // Nested view; pass it as the view
                            $sectionView = $section;
                        } else {
                            // Iteration
                            $renderedSection = '';
                            foreach ($section as $sectionView) {
                                $renderedSection .= $this->render($data['content'], $sectionView);
                            }
                            $rendered .= $renderedSection;
                            break;
                        }
                    } elseif (is_callable($section) && $this->isValidCallback($section)) {
                        // Higher order section
                        // Execute the callback, passing it the section's template
                        // string, as well as a renderer lambda.
                        $mustache       = $this->mustache;
                        $invokedPragmas = $this->invokedPragmas;
                        $rendered .= call_user_func(
                            $section,
                            $data['template'],
                            function ($text) use ($renderer, $mustache, $view, $partials) {
                                $tokens = $mustache->tokenize($text);
                                return $renderer->render($tokens, $view, $partials);
                            }
                        );
                        $this->registerPragmas($invokedPragmas);
                        break;
                    } elseif (is_object($section)) {
                        // In this case, the child object is the view.
                        $sectionView = $section;
                    } else {
                        // All other types, simply pass the current view
                        $sectionView = $view;
                    }

                    // Render the section
                    $invokedPragmas = $this->invokedPragmas;
                    $rendered .= $this->render($data['content'], $sectionView);
                    $this->registerPragmas($invokedPragmas);
                    break;
                case Lexer::TOKEN_SECTION_INVERT:
                    if ($inLoop) {
                        // In a loop, with scalar values; skip
                        break;
                    }
                    $section = $this->getValue($data['name'], $view);
                    if ($section) {
                        // If a value exists for the section, we skip it
                        $rendered .= '';
                        break;
                    }

                    // Otherwise, we render it
                    $invokedPragmas = $this->invokedPragmas;
                    $rendered .= $this->render($data['content'], $view);
                    $this->registerPragmas($invokedPragmas);
                    break;
                case Lexer::TOKEN_PLACEHOLDER:
                    if ($inLoop) {
                        // In a loop, with scalar values; skip
                        break;
                    }
                    $rendered .= $this->render($data['content'], $view);
                    break;
                case Lexer::TOKEN_PARTIAL:
                    if ($inLoop) {
                        // In a loop, with scalar values; skip
                        break;
                    }
                    $invokedPragmas = $this->invokedPragmas;
                    $this->clearInvokedPragmas();
                    if (! isset($data['tokens'])) {
                        $name = $data['partial'];
                        if (isset($partials[$data['partial']])) {
                            // Partial invoked is an aliased partial
                            $rendered .= $this->render($partials[$data['partial']], $view);
                        } else {
                            $partialTokens = $this->mustache->tokenize($data['partial']);
                            $rendered .= $this->render($partialTokens, $view);
                        }
                        $this->registerPragmas($invokedPragmas);
                        break;
                    }
                    $rendered .= $this->render($data['tokens'], $view);
                    $this->registerPragmas($invokedPragmas);
                    break;
                case Lexer::TOKEN_PRAGMA:
                    $this->registerPragma($data);
                    break;
                case Lexer::TOKEN_DELIM_SET:
                case Lexer::TOKEN_COMMENT:
                default:
                    // do nothing; only necessary for tokenization/parsing
                    break;
            }
        }
        return $rendered;
    }
1083178
public function on(string $eventIdentifier, \Closure $callback): void
    {
        $this->eventCallbacks[$eventIdentifier][] = $callback;
    }
296881
public function setTemplateInheritorsCssToUpdate(View $view)
    {
        if (!($view instanceof Template)) {
            return;
        }
        foreach ($view->getInheritors() as $inheritor) {
            $inheritor->setCssUpToDate(false);
            $this->uow->persist($inheritor);
            $this->setTemplateInheritorsCssToUpdate($inheritor);
        }
    }