Set the template content from a string

@param  string  $content  The template content
@return KTemplateEngineTwig
437921
public function loadString($content, $url = null)
    {
        parent::loadString($content);

        //Let twig load the content by proxiing through the getSource() method.
        $this->_twig_template = $this->_twig->loadTemplate($content);

        //Push the template on the stack
        array_push($this->_stack, $url);
        return $this;
    }
873580
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt_entry) {
                $ctt .= $ctt_entry;
            }
            $content = $ctt;
        }
        return (string) $content;
    }
1211548
private function mountContent($content)
    {
        if ($this->extended || empty($content)) {
            //No blocks or text can exists outside parent template blocks
            return;
        }

        if (is_array($content)) {
            $plainContent = '';
            foreach ($content as $token) {
                $plainContent .= $token[HtmlTokenizer::TOKEN_CONTENT];
            }

            $content = $plainContent;
        }

        $matches = $this->compiler->getSyntax()->parseBlock($content);
        if (!empty($matches)) {
            $chunks = explode($matches[0], $content);

            //We expecting first chunk to be string (before block)
            $this->mountContent(array_shift($chunks));

            $this->mountBlock(
                $matches['name'],
                isset($matches['default']) ? $matches['default'] : ''
            );

            //Rest of content (after block)
            $this->mountContent(join($matches[0], $chunks));

            return;
        }

        if (is_string(end($this->nodes))) {
            $this->nodes[key($this->nodes)] .= $content;

            return;
        }

        $this->nodes[] = $content;
    }
495544
public function parseTemplateContent($content, $template = "")
    {
        return $this->getParser()->compileString(
            $content,
            $template,
            Director::isDev() && SSViewer::config()->uninherited('source_file_comments')
        );
    }
30181
public function setBody($content, $type = 'text/html', $charset = 'utf-8')
    {
        $this->message->setBody($content, $type, $charset);

        return $this;
    }
937552
public function prepare(
        $content,
        ThemeInterface $theme,
        TemplateInterface $template,
        ZoneInterface $zone,
        ComponentInterface $component
    ) {
        $this->contextStack->push(
            $this->contextBuilder
                ->setContent($content)
                ->setTheme($theme)
                ->setTemplate($template)
                ->setZone($zone)
                ->setComponent($component)
            ->createContext()
        );

        return $this;
    }
626193
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt) {
                $content .= $ctt;
            }
            $content = $ctt;
        }
        $_escaped_output = strip_tags((string) $content);
        if ($_escaped_output != (string) $content) {
            if (preg_match('/(.*)<body(.*)</body>/i', (string) $content, $matches)) {
                $_output = $matches[0];
            } else {
                $_output = (string) $content;
            }
            $content = Html2Text::convert($_output);
        }
        return (string) $content;
    }
354496
public function addContent(string $content): \Symfony\Component\HttpFoundation\Response
    {
        return $this->setContent($this->getContent() . $content);
    }
42727
public function setContent($content)
    {
        $this->content = null;
        if ($content === null) {
            return;
        }

        if (TypeHandling::isSimpleType(gettype($content)) && !is_array($content)) {
            $this->content = (string)$content;
        }

        if (is_resource($content)) {
            $this->content = $content;
        }

        return $this;
    }
244484
public function setContent(Content $content)
    {
        $this->contentTypeName = $content->getType()->getName();
        $this->contentId = $content->getContentId();

        return parent::setContent($content);
    }
1021508
public function setContent($content)
    {
        if (is_array($content) || $content instanceof ArrayAccess || $content instanceof JsonSerializable) {
            $this->headers->add(['Content-Type' => 'application/json; charset=utf-8']);
            $content = json_encode($content, JSON_UNESCAPED_UNICODE);
        }

        parent::setContent($content);
        parent::setCharset('utf-8');

        return $this;
    }
961807
public function html($content = '')
    {
        $this->format = 'html';

        if (! str_empty($content)) {
            $this->content($content);
        }

        return $this;
    }
1238217
private function replaceIndexTemplateContents($content)
    {
        /* Index View Page */
        //replace table headers - <th> {%tableColumns%}</th>
        //replace table td - {%controllerColumns%}

        $content = str_replace('#controllerName#', $this->controller, $content);
        $content = str_replace('#ControllerName#', Inflector::classify($this->controller), $content);
        $content = str_replace('{%primaryKey%}',
            $this->command->table()->getPrimaryKey(),
            $content
        );

        $column = '';

        $column = $this->replaceTableElements('th');
        $content = str_replace('{#thColumns#}', $column.PHP_EOL, $content);

        $column = $this->replaceTableElements('td');
        $content = str_replace('{#tdColumns#}', $column.PHP_EOL, $content);

        return $content;
    }
677224
public function setContent($content)
    {
        if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) {
            throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content)));
        }

        $this->content = (string) $content;

        return $this;
    }
73817
public function setTemplate($template)
    {
        if (is_string($template)) {
            $template = new TemplateView($template);
        }
        $template->mergeData([
            'layout' => $this
        ]);
        $this->addChild(new Part($template, 'template'));
        return $this;
    }
701516
public function setContent(string $content, ?StreamFactoryInterface $streamFactory = null): WebResourceInterface
    {
        $response = null;
        $contentType = $this->contentType;

        if ($this->response && empty($streamFactory)) {
            throw UnwritableContentException::create();
        }

        if ($this->response) {
            $responseBody = $streamFactory->createFromString($content);
            $response = $this->response->withBody($responseBody);
            $contentType = null;
        }

        return $this->createNewInstance([
            WebResourceProperties::ARG_CONTENT_TYPE => $contentType,
            WebResourceProperties::ARG_CONTENT => $content,
            WebResourceProperties::ARG_RESPONSE => $response,
        ]);
    }
537138
public function setContent($content)
    {
        $this->original = $content;

        // If the content is "JSONable" we will set the appropriate header and convert
        // the content to JSON. This is useful when returning something like models
        // from routes that will be automatically transformed to their JSON form.
        if ($this->shouldBeJson($content)) {
            $this->header('Content-Type', 'application/json');

            $content = $this->morphToJson($content);
        }

        // If this content implements the "Renderable" interface then we will call the
        // render method on the object so we will avoid any "__toString" exceptions
        // that might be thrown and have their errors obscured by PHP's handling.
        elseif ($content instanceof Renderable) {
            $content = $content->render();
        }

        parent::setContent($content);

        return $this;
    }