Adding an HTML data attribute to rows in Views I've tried rewriting the row and also theming the Views row, but I'm not having any luck. Maybe I'm doing something wrong.

I have the format of my view as 'Unformatted View', and in the format settings there is an option to specify the 'Row Class', which is then added to each row. However, I need to add a data-attribute to my rows in addition to a class. The data-attribute needs to be one of the fields - the Taxonomy Term name field (in lower case).

For instance, my field is Taxonomy Term Name. Currently, the HTML markup of each row looks like this:

&lt;div class="my-row"&gt;Term&lt;/a&gt;


However, I need it to look like this:

&lt;div class="my-row data-attribute=".term"&gt;Term&lt;/a&gt;


I am finding this fairly difficult to accomplish, and can't find much about it online. Could anyone be of help?
The easiest way that I found to create unique attribute per views row is to override the template file to exclude the outer div and output each row using Global: Custom text in the view excluding from display all fields and including them in the custom text field.

Here is in more detail 


go to your view and click Advanced &gt; theme &gt; information
in style output line the bolded file name is the currently used template (let assume views-view-unformatted.tpl.php)
get the name next to the bolded file name (could be something like this views-view-unformatted--VIEWNAME.tpl.php)
copy /all/modules/views/theme/views-view-unformatted.tpl.php to your THEMENAME/views-view-unformatted--VIEWNAME.tpl.php 
edit it and modify so it does not output the outer row div. It could look like this for unformatted style

&lt;?php if (!empty($title)): ?&gt;
  &lt;h3&gt;&lt;?php print $title; ?&gt;&lt;/h3&gt;
&lt;?php endif; ?&gt;
&lt;?php foreach ($rows as $id =&gt; $row): ?&gt;
    &lt;?php print $row; ?&gt;
&lt;?php endforeach; ?&gt;

edit all view field and check Exclude from display
add Global: Custom text and add all fields in the content using replacement pattern
your outer div in Custom text could look like this 

&lt;div class="views-row my-row" data-attribute=".[field_FIELDNAME]"&gt;[field_FIELDNAME]&lt;/div&gt; 

refresh the cache and make sure in steps 1,2, your new template is used