public function insertTemplate(HookRenderEvent $event, $code)
    {
        if (array_key_exists($code, $this->templates)) {
            $templates = explode(';', $this->templates[$code]);

            // Concatenate arguments and template variables,
            // giving the precedence to arguments.
            $allArguments = $event->getTemplateVars() + $event->getArguments();

            foreach ($templates as $template) {
                list($type, $filepath) = $this->getTemplateParams($template);

                if ("render" === $type) {
                    $event->add($this->render($filepath, $allArguments));
                    continue;
                }

                if ("dump" === $type) {
                    $event->add($this->render($filepath));
                    continue;
                }

                if ("css" === $type) {
                    $event->add($this->addCSS($filepath));
                    continue;
                }

                if ("js" === $type) {
                    $event->add($this->addJS($filepath));
                    continue;
                }

                if (method_exists($this, $type)) {
                    $this->{$type}($filepath, $allArguments);
                }
            }
        }
    }