Hi devs,
Right now the HTML we generated is really not very nice in some places. For example for LTs, here’s what we get:
<tr>
<td class="xwiki-livetable-display-container">
<table class="xwiki-livetable-display">
<thead class="xwiki-livetable-display-header">
<tr>
<th scope="col" class="xwiki-livetable-display-header-text avatar
">
Picture
</th>
<th scope="col" class="xwiki-livetable-display-header-text
sortable selected asc">
<label for="xwiki-livetable-userdirectory-filter-2"> <a data-rel="doc.name"> User ID
</a> </label> </th>
<th scope="col" class="xwiki-livetable-display-header-text
sortable asc">
<label for="xwiki-livetable-userdirectory-filter-3"> <a data-rel="first_name"> First Name
</a> </label> </th>
<th scope="col" class="xwiki-livetable-display-header-text
sortable asc">
<label for="xwiki-livetable-userdirectory-filter-4"> <a data-rel="last_name"> Last Name
</a> </label> </th>
<th scope="col" class="xwiki-livetable-display-header-text
hidden ">
xe.userdirectory.active
</th>
</tr>
<tr class="xwiki-livetable-display-filters">
<td class="xwiki-livetable-display-header-filter">
</td>
<td class="xwiki-livetable-display-header-filter">
<input id="xwiki-livetable-userdirectory-filter-2" name="doc.name" type="text"
title="Filter for the User ID column" />
</td>
<td class="xwiki-livetable-display-header-filter">
<input id="xwiki-livetable-userdirectory-filter-3" name="first_name" type="text"
title="Filter for the xe.userdirectory.first_name column" />
</td>
<td class="xwiki-livetable-display-header-filter">
<input id="xwiki-livetable-userdirectory-filter-4" name="last_name" type="text"
title="Filter for the xe.userdirectory.last_name column" />
</td>
<td class="xwiki-livetable-display-header-filter">
</td>
</tr>
<tr class="xwiki-livetable-initial-message">
<td colspan="5">
<div class="warningmessage">The environment prevents the table from loading data.</div>
</td>
</tr>
</thead>
<tbody id="userdirectory-display" class="xwiki-livetable-display-body hyphenate">
<tr><td colspan="5"> </td></tr>
</tbody>
</table>
</td>
</tr>
And the code for this is found in macros.vm, for example:
#macro (livetable_filters $columns $columnsProperties $xclassName)
<tr class="xwiki-livetable-display-filters">
#foreach ($column in $columns)
#set ($columnProperties = $columnsProperties.get($column))
## Note: Also display a cell when hidden in order to have the correct number of TDs in the table and so that it
## passes validation.
<td class="xwiki-livetable-display-header-filter">
#if ($columnProperties.type != 'hidden')
#if ($columnProperties.filterable != false && "$!column" != '_actions')
#set ($columnXClassName = $columnProperties.get('class'))
#set ($columnXPropertyName = $column)
#if (!$columnXClassName)
#if ($column.startsWith('doc.'))
#set ($columnXClassName = 'XWiki.DocumentClass')
#set ($columnXPropertyName = $column.substring(4))
#else
#set ($columnXClassName = $xclassName)
#end
#end
#set ($xclass = $xwiki.getDocument($columnXClassName).getxWikiClass())
#set ($xproperty = $xclass.get($columnXPropertyName))
#livetable_filter($column $columnProperties $xproperty)
#end
#end
</td>
#end
</tr>
#end
This code is nicely indented but since we don’t remove extra new spaces as we do for the {{velocity}}
macro, we end up with some really not nice formatting in the generated HTML.
Since we have a TemplateManager, I was wondering if it would make sense to do some filtering in it to remove leading white spaces.
WDYT?
Thanks