From c68896f9c70522919d260cb5a0420faec0d37ea2 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 24 May 2013 10:35:51 -0700 Subject: [PATCH] Issue #1843746 by joelpittet, trrroy, shanethehat, tlattimore, damiankloip, jastraat, dawehner, thedavidmeister, Cottser, Kevin Morse: Convert views/templates/views-view-field.tpl.php to Twig . --- .../templates/views-view-field.html.twig | 28 +++++++++++++++++++ .../views/templates/views-view-field.tpl.php | 25 ----------------- core/modules/views/views.theme.inc | 13 ++++++--- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 core/modules/views/templates/views-view-field.html.twig delete mode 100644 core/modules/views/templates/views-view-field.tpl.php diff --git a/core/modules/views/templates/views-view-field.html.twig b/core/modules/views/templates/views-view-field.html.twig new file mode 100644 index 00000000000..759eb226278 --- /dev/null +++ b/core/modules/views/templates/views-view-field.html.twig @@ -0,0 +1,28 @@ +{# +/** + * @file + * Default theme implementation for a single field in a view. + * + * It is not actually used in default views, as this is registered as a theme + * function which has better performance. For single overrides, the template is + * perfectly okay. + * + * Available variables: + * - view: The view that the field belongs to. + * - field: The field handler that can process the input. + * - row: The raw result of the database query that generated this field. + * - output: The processed output that will normally be used. + * + * When fetching output from the row this construct should be used: + * data = row[field.field_alias] + * + * The above will guarantee that you'll always get the correct data, regardless + * of any changes in the aliasing that might happen if the view is modified. + * + * @see template_preprocess() + * @see template_preprocess_views_view_field() + * + * @ingroup themeable + */ +#} +{{ output }} diff --git a/core/modules/views/templates/views-view-field.tpl.php b/core/modules/views/templates/views-view-field.tpl.php deleted file mode 100644 index 91d92eee954..00000000000 --- a/core/modules/views/templates/views-view-field.tpl.php +++ /dev/null @@ -1,25 +0,0 @@ -{$field->field_alias} - * - * The above will guarantee that you'll always get the correct data, - * regardless of any changes in the aliasing that might happen if - * the view is modified. - */ -?> - diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 95a24b45e82..7b4747541fb 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -328,11 +328,16 @@ function theme_views_view_field($vars) { } /** - * Process a single field within a view. + * Prepares variables for views field templates. * - * This preprocess function isn't normally run, as a function is used by - * default, for performance. However, by creating a template, this - * preprocess should get picked up. + * Default template: views-view-field.html.twig. + * + * @param array $vars + * An associative array containing: + * - field: The field handler object for the current field. + * - row: Object representing the raw result of the SQL query for the current + * field. + * - view: Instance of the ViewExecutable object for the parent view. */ function template_preprocess_views_view_field(&$vars) { $vars['output'] = $vars['field']->advanced_render($vars['row']);