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 0000000..1db67d1 --- /dev/null +++ b/core/modules/views/templates/views-view-field.html.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Default theme implementation for a single field in a view. + * + * Available variables: + * - view: The view object. + * - field: The field handler object that can process the input. + * - row: The raw SQL result that can be used. + * - 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 + */ +#} +{% spaceless %} + {{ output }} +{% endspaceless %} 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 91d92ee..0000000 --- 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.module b/core/modules/views/views.module index 8e2a378..d09b87c 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -108,7 +108,7 @@ function views_theme($existing, $type, $theme, $path) { // Default view themes $hooks['views_view_field'] = $base + array( - 'pattern' => 'views_view_field__', + 'template' => 'views-view-field', 'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL), ); $hooks['views_view_grouping'] = $base + array( diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 4178bac..025ba12 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -319,28 +319,17 @@ function template_preprocess_views_view_grouping(&$vars) { } /** - * Display a single views field. + * Prepares variables for views field templates. * - * Interesting bits of info: - * $field->field_alias says what the raw value in $row will be. Reach it like - * this: @code { $row->{$field->field_alias} @endcode - */ -function theme_views_view_field($vars) { - $view = $vars['view']; - $field = $vars['field']; - $row = $vars['row']; - return $vars['output']; -} - -/** - * Process a single field within a view. + * Default template: views-view-field.html.twig. * - * 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. + * @param array $variables + * An associative array containing: + * - field: @todo. + * - row: @todo. */ -function template_preprocess_views_view_field(&$vars) { - $vars['output'] = $vars['field']->advanced_render($vars['row']); +function template_preprocess_views_view_field(&$variables) { + $variables['output'] = $variables['field']->advanced_render($variables['row']); } /**