Hi,

Drupal 7.33 introduced a useful theme_debug config option to inspect template suggested and used:
https://www.drupal.org/drupal-7.33-release-notes

The effect of this option is that debug markup is inserted into Drupal output.

However when this option is enabled, Views Data Export does not prevent debug markup to be inserted in rendered results, breaking CSV and XML formats.

Here is an example of a rendered data export CSV display:

<!-- THEME DEBUG -->
<!-- CALL: theme('views_data_export') -->
<!-- BEGIN OUTPUT from 'sites/all/modules/views_data_export/theme/views-data-export.tpl.php' -->


<!-- THEME DEBUG -->
<!-- CALL: theme('views_data_export_csv_header') -->
<!-- BEGIN OUTPUT from 'sites/all/modules/views_data_export/theme/views-data-export-csv-header.tpl.php' -->
"Name","","Roles","Member for","Last access"

<!-- END OUTPUT from 'sites/all/modules/views_data_export/theme/views-data-export-csv-header.tpl.php' -->



<!-- THEME DEBUG -->
<!-- CALL: theme('views_data_export_csv_body') -->
<!-- BEGIN OUTPUT from 'sites/all/modules/views_data_export/theme/views-data-export-csv-body.tpl.php' -->
"User 1","user-1@example.com","","4 days 2 hours","4 days 1 hour ago"
"User 2","user-2@example.com","","4 days 4 hours","4 days 26 min ago"
"User 3","user-3@example.com","","4 days 8 hours","4 days 5 hours ago"
"User 4","user-4@example.com","premium","4 days 23 hours",""

The following patch disables this option before rendering the view.

CommentFileSizeAuthor
#1 2540616-disable-theme-debug.patch992 bytesmanu manu

Comments

manu manu’s picture

StatusFileSize
new992 bytes
manu manu’s picture

Status: Active » Needs review
nategasser’s picture

Patch in #1 worked for me, however, debug comments still show up within the Views UI when you're previewing. Adding the same 2 lines at the beginning of the "preview()" function (line ~552) solves that problem.

steven jones’s picture

I'm not sure I see why VDE needs this?

If you're trying to use the theme debug global then you probably do want random things appearing in your exports to help you theme, if you don't want them, then turn it off. No?

klidifia’s picture

Status: Needs review » Closed (works as designed)

Yes it seems that Views is adhering to the theme_debug configuration as it should; hard coding the disabling of it is not the right way to go.

Works as expected, if you want to disable it in certain environments it should be done at a higher level.

e.g. in my development environment I want to verify export data I will simply temporarily disable theme_debug in settings.php:

$conf['theme_debug'] = FALSE;

matthieuscarset’s picture

For the record, it is possible to disable the theme debug output by calling the Twig service right before your rendering.

For instance :

      $node = \Drupal::entityTypeManager()->getStorage('node')->load(1);
      $build = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node);

      // Make sure no debug output in XML.
      \Drupal::service('twig')->disableDebug();

      $output = \Drupal::service('renderer')->renderPlain($build);