Craft\AmFormsService::renderDisplayTemplate PHP Method

renderDisplayTemplate() public method

Render a display (front-end displayForm) template.
public renderDisplayTemplate ( string $defaultTemplate, string $overrideTemplate, array $variables ) : string
$defaultTemplate string Which default template are we looking for?
$overrideTemplate string Which override template was given?
$variables array Template variables.
return string
    public function renderDisplayTemplate($defaultTemplate, $overrideTemplate, $variables)
    {
        // Get the template path
        $templateInfo = $this->getDisplayTemplateInfo($defaultTemplate, $overrideTemplate);
        // Override Craft template path
        $oldPath = method_exists(craft()->templates, 'getTemplatesPath') ? craft()->templates->getTemplatesPath() : craft()->path->getTemplatesPath();
        method_exists(craft()->templates, 'setTemplatesPath') ? craft()->templates->setTemplatesPath($templateInfo['path']) : craft()->path->setTemplatesPath($templateInfo['path']);
        // Get template HTML
        $html = craft()->templates->render($templateInfo['template'], $variables);
        // Reset templates path
        method_exists(craft()->templates, 'setTemplatesPath') ? craft()->templates->setTemplatesPath($oldPath) : craft()->path->setTemplatesPath($oldPath);
        // Return rendered template!
        return $html;
    }