function fft_render in Field Formatter Template 8
Same name and namespace in other branches
- 8.2 fft.module \fft_render()
- 7 fft.module \fft_render()
Render template with variables.
Parameters
string $template_file: Template name.
array $variables: Variables for template.
Return value
string Rendered template.
2 calls to fft_render()
- fft_field_formatter_render in ./
fft.module - Render field formatter.
- template_preprocess_views_formatter_template in modules/
vff/ vff.theme.inc - Prepares variables for views carousel template.
File
- ./
fft.module, line 275 - Field formatter template.
Code
function fft_render($template_file, array $variables) {
if (!is_file($template_file)) {
return "";
}
$render_function = 'twig_render_template';
$twig_debug = \Drupal::getContainer()
->get('twig')
->isDebug();
global $theme_engine;
if (isset($theme_engine)) {
if (function_exists($theme_engine . '_render_template')) {
$render_function = $theme_engine . '_render_template';
}
}
$variables['theme_hook_original'] = '';
$event = new PreProcess($template_file, $variables);
$event_dispatcher = \Drupal::getContainer()
->get('event_dispatcher');
$event_dispatcher
->dispatch(PreProcess::EVENT, $event);
if ($twig_debug) {
\Drupal::getContainer()
->get('twig')
->disableDebug();
}
$render_output = $render_function($template_file, $variables);
if ($twig_debug) {
$debug_prefix = "\n\n<!-- THEME DEBUG -->";
$debug_prefix .= "\n<!-- THEME HOOK: '" . Html::escape($variables['theme_hook_original']) . "' -->";
$debug_prefix .= "\n<!-- BEGIN OUTPUT from '" . Html::escape($template_file) . "' -->\n";
$debug_suffix = "\n<!-- END OUTPUT from '" . Html::escape($template_file) . "' -->\n\n";
$render_output = $debug_prefix . $render_output . $debug_suffix;
\Drupal::getContainer()
->get('twig')
->enableDebug();
}
return $render_output;
}