Index: Main/SolrSearch.xml
===================================================================
--- Main/SolrSearch.xml	(revision 24079)
+++ Main/SolrSearch.xml	(revision 24081)
@@ -689,7 +689,7 @@
 #set ($wildcardPattern = $regextool.compile('^\(.*\*.*\)$'))
 
 #macro (displaySearchForm)
-  {{html}}
+  {{html clean="false"}}
   &lt;form class="search-form half" action=""&gt;
     &lt;div class="hidden"&gt;
       &lt;input type="hidden" name="sort" value="$!escapetool.xml($sort)"/&gt;
@@ -727,7 +727,7 @@
     #set ($debugMap = $searchResponse.debugMap)
     #if ($debugMap)
 
-      {{html}}
+      {{html clean="false"}}
       &lt;dl&gt;
         &lt;dt&gt;Query Parser&lt;/dt&gt;
         &lt;dd&gt;$!escapetool.xml($debugMap.get('QParser'))&lt;/dd&gt;
@@ -802,7 +802,7 @@
     #set ($facetRequestValues = $request.getParameterValues($facetRequestParameter))
     #set ($facetValuesLimit = $request.getParameter("l_$facetField.name"))
     (% class="search-facet#if ($facetRequestValues || $facetValuesLimit) expanded#end" %)(((
-      {{html}}
+      {{html clean="false"}}
       #displaySearchFacetHeader($facetField)
       #displaySearchFacetBody($facetField)
       {{/html}}
@@ -850,12 +850,7 @@
       #set ($facetDisplayer = $solrConfig.facetDisplayersByPropertyType.get($property.classType))
     #end
     #if ($facetDisplayer)
-      #set ($facetDisplayer = $xwiki.getDocument($facetDisplayer))
-      #if ("$!facetDisplayer.content" != '')
-        $!doc.getRenderedContent($facetDisplayer.content, $facetDisplayer.syntax.toIdString(), 'xhtml/1.0')
-      #else
-        #displaySearchFacetValues($facetValues)
-      #end
+      #evaluate("${escapetool.h}${facetDisplayer}(${escapetool.d}facetValues)")
     #else
       #displaySearchFacetValues($facetValues)
     #end
@@ -985,14 +980,17 @@
     'defaultItemsPerPage': $rows,
     'position': 'top'
   })
-  {{html}}#pagination($paginationParameters){{/html}}
-  (% class="search-results" %)(((
-    #foreach ($searchResult in $results)
-      #displaySearchResult($searchResult)
-    #end
-  )))
+
+ {{html}}
+  #pagination($paginationParameters)
+  &lt;div class="search-results"&gt;
+      #foreach ($searchResult in $results)
+        #displaySearchResult($searchResult)
+      #end
+  &lt;/div&gt;
   #set ($discard = $paginationParameters.put('position', 'bottom'))
-  {{html}}#pagination($paginationParameters){{/html}}
+  #pagination($paginationParameters)
+  {{/html}}
 
   #displayRSSLink()
 #end
@@ -1020,12 +1018,9 @@
   #set ($searchResultDocumentReference = $services.model.createDocumentReference($searchResult.wiki,
     $searchResult.space, $searchResult.name))
   #set ($searchResultDocument = $xwiki.getDocument($searchResultDocumentReference))
-  (% class="search-result type-$searchResult.type.toLowerCase()" %)(((
-    ## We use the HTML macro here mainly because we don't have a way to escape the wiki syntax in the data provided by the user.
-    {{html}}
+  &lt;div class="search-result type-$searchResult.type.toLowerCase()"&gt;
     #evaluate("${escapetool.h}displaySearchResult_$searchResult.type.toLowerCase()(${escapetool.d}searchResult)")
     #displaySearchResultHighlighting($searchResult)
-    {{/html}}
     #if ($debug)
 
       ## Scoring debug data.
@@ -1032,11 +1027,9 @@
       ## The reason we used a separate HTML block with no cleaning is because the scoring debug data may contain some
       ## characters that are considered invalid by JDOM library which is used for parsing the HTML when cleaning is on.
       ## E.g. "0x0 is not a legal XML character" (org.jdom.IllegalDataException).
-      {{html clean="false"}}
       &lt;div class="search-result-debug"&gt;$!escapetool.xml($searchResponse.explainMap.get($searchResult.id))&lt;/div&gt;
-      {{/html}}
     #end
-  )))
+  &lt;/div&gt;
 #end
 
 #macro (displaySearchResult_document $searchResult)
Index: Main/SolrWikiFacet.xml
===================================================================
--- Main/SolrWikiFacet.xml	(revision 24079)
+++ Main/SolrWikiFacet.xml	(revision 24081)
@@ -21,8 +21,8 @@
 <minorEdit>false</minorEdit>
 <syntaxId>xwiki/2.1</syntaxId>
 <hidden>true</hidden>
-<content>{{velocity}}
-#macro (displaySearchFacetValue_wiki $wikiName)
+<content>{{velocity output="false"}}
+#macro (displaySearchFacetValueForWiki $wikiName)
   #set ($wikiPrettyName = $services.wiki.getById($wikiName).prettyName)
   #if ("$!wikiPrettyName.trim()" == '')
     #set ($wikiPrettyName = $wikiName)
@@ -29,15 +29,18 @@
   #end
   $escapetool.xml($wikiPrettyName)
 #end
-#set ($actualFacetValues = $facetValues)
-## If the list of wikis that are searchable from the main wiki is restricted then we need to hide some values.
-#if ($solrConfig.wikisSearchableFromMainWiki &amp;&amp; $xcontext.isMainWiki() &amp;&amp; !$facetRequestValues)
-  #set ($actualFacetValues = [])
-  #foreach ($facetValue in $facetValues)
-    #if ($solrConfig.wikisSearchableFromMainWiki.contains($facetValue.name))
-      #set ($discard = $actualFacetValues.add($facetValue))
+
+#macro (displaySearchFacetValues_wiki $facetValues)
+  #set ($actualFacetValues = $facetValues)
+  ## If the list of wikis that are searchable from the main wiki is restricted then we need to hide some values.
+  #if ($solrConfig.wikisSearchableFromMainWiki &amp;&amp; $xcontext.isMainWiki() &amp;&amp; !$facetRequestValues)
+    #set ($actualFacetValues = [])
+    #foreach ($facetValue in $facetValues)
+      #if ($solrConfig.wikisSearchableFromMainWiki.contains($facetValue.name))
+        #set ($discard = $actualFacetValues.add($facetValue))
+      #end
     #end
   #end
+  #displaySearchFacetValues($actualFacetValues {} 'displaySearchFacetValueForWiki')
 #end
-{{html}}#displaySearchFacetValues($actualFacetValues {} 'displaySearchFacetValue_wiki'){{/html}}
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrClassFacet.xml
===================================================================
--- Main/SolrClassFacet.xml	(revision 24079)
+++ Main/SolrClassFacet.xml	(revision 24081)
@@ -21,8 +21,8 @@
 <minorEdit>false</minorEdit>
 <syntaxId>xwiki/2.1</syntaxId>
 <hidden>true</hidden>
-<content>{{velocity}}
-#macro (displaySearchFacetValue_class $classFullName)
+<content>{{velocity output="false"}}
+#macro (displaySearchFacetValueForClass $classFullName)
   #set ($classReference = $services.model.resolveDocument($classFullName, 'default'))
   #set ($hint = $services.localization.render('solr.field.class.definedBy',
     [$classReference.lastSpaceReference.name, $classReference.name]))
@@ -39,5 +39,8 @@
   #end
   &lt;span title="$escapetool.xml($hint)"&gt;$escapetool.xml($classPrettyName)&lt;/span&gt;
 #end
-{{html}}#displaySearchFacetValues($facetValues {} 'displaySearchFacetValue_class'){{/html}}
+
+#macro (displaySearchFacetValues_class $facetValues)
+  #displaySearchFacetValues($facetValues {} 'displaySearchFacetValueForClass')
+#end
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrSearchConfig.xml
===================================================================
--- Main/SolrSearchConfig.xml	(revision 24079)
+++ Main/SolrSearchConfig.xml	(revision 24081)
@@ -56,23 +56,23 @@
     'locale': [$xcontext.language, '']
   },
   'facetDisplayers': {
-    'type': 'Main.SolrTypeFacet',
-    'wiki': 'Main.SolrWikiFacet',
-    'locale': 'Main.SolrLocaleFacet',
-    'author': 'Main.SolrUserFacet',
-    'creator': 'Main.SolrUserFacet',
-    'attauthor': 'Main.SolrUserFacet',
-    'date': 'Main.SolrDateFacet',
-    'creationdate': 'Main.SolrDateFacet',
-    'attdate': 'Main.SolrDateFacet',
-    'class': 'Main.SolrClassFacet',
-    'attsize': 'Main.SolrFileSizeFacet',
-    'mimetype': 'Main.SolrMediaTypeFacet'
+    'type': 'displaySearchFacetValues_type',
+    'wiki': 'displaySearchFacetValues_wiki',
+    'locale': 'displaySearchFacetValues_locale',
+    'author': 'displaySearchFacetValues_user',
+    'creator': 'displaySearchFacetValues_user',
+    'attauthor': 'displaySearchFacetValues_user',
+    'date': 'displaySearchFacetValues_date',
+    'creationdate': 'displaySearchFacetValues_date',
+    'attdate': 'displaySearchFacetValues_date',
+    'class': 'displaySearchFacetValues_class',
+    'attsize': 'displaySearchFacetValues_filesize',
+    'mimetype': 'displaySearchFacetValues_mimetype'
   },
   'facetDisplayersByPropertyType': {
-    'Date': 'Main.SolrDateFacet',
-    'Users': 'Main.SolrUserFacet',
-    'Groups': 'Main.SolrUserFacet'
+    'Date': 'displaySearchFacetValues_date',
+    'Users': 'displaySearchFacetValues_user',
+    'Groups': 'displaySearchFacetValues_user'
   },
   'facetPaginationStep': 5,
   'facet': {
@@ -132,5 +132,30 @@
   ## Merge the provided configuration with the default configuration.
   #set ($discard = $__defaultSolrConfig.putAll($solrConfig))
 #end
+{{/velocity}}
+
+{{velocity}}
+#if (!$!solrConfig || !$!solrConfig.facetDisplayers)
+
+{{include reference="Main.SolrTypeFacet" /}}
+
+{{include reference="Main.SolrWikiFacet" /}}
+
+{{include reference="Main.SolrLocaleFacet" /}}
+
+{{include reference="Main.SolrClassFacet" /}}
+
+{{include reference="Main.SolrFileSizeFacet" /}}
+
+{{include reference="Main.SolrMediaTypeFacet" /}}
+
+#end
+#if (!$!solrConfig || (!$!solrConfig.facetDisplayers &amp;&amp; !$!solrConfig.facetDisplayersByPropertyType))
+
+{{include reference="Main.SolrDateFacet" /}}
+
+{{include reference="Main.SolrUserFacet" /}}
+
+#end
 #set ($solrConfig = $__defaultSolrConfig)
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrFileSizeFacet.xml
===================================================================
--- Main/SolrFileSizeFacet.xml	(revision 24079)
+++ Main/SolrFileSizeFacet.xml	(revision 24081)
@@ -22,7 +22,7 @@
 <syntaxId>xwiki/2.1</syntaxId>
 <hidden>true</hidden>
 <content>{{velocity output="false"}}
-#macro (displaySearchFacetValues_fileSize $facetValues)
+#macro (displaySearchFacetValuesForFileSize $facetValues)
   ##
   ## Predefined size intervals, specified in bytes.
   ##
@@ -120,10 +120,11 @@
     $escapetool.xml($services.localization.render('solr.facet.size.any'))
   #end
 #end
-{{/velocity}}
 
-{{velocity}}
-#if ($facetValues)
-  {{html}}#displaySearchFacetValues_fileSize($facetValues){{/html}}
+#macro (displaySearchFacetValues_filesize $facetValues)
+  #if ($facetValues)
+    #displaySearchFacetValuesForFileSize($facetValues)
+  #end
 #end
-{{/velocity}}</content></xwikidoc>
\ No newline at end of file
+{{/velocity}}
+</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrDateFacet.xml
===================================================================
--- Main/SolrDateFacet.xml	(revision 24079)
+++ Main/SolrDateFacet.xml	(revision 24081)
@@ -269,7 +269,7 @@
 #set ($defaultDateFormat = 'yyyy/MM/dd HH:mm')
 #set ($iso8601DateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'")
 
-#macro (displaySearchFacetValues_date $facetValues)
+#macro (displaySearchFacetValuesForDate $facetValues)
   #set ($discard = $xwiki.ssx.use('Main.SolrDateFacet'))
   #set ($discard = $xwiki.jsx.use('Main.SolrDateFacet'))
   ##
@@ -507,12 +507,16 @@
     })))
   $response.sendRedirect($xredirect)
 #end
+
+#macro (displaySearchFacetValues_date $facetValues)
+  #if ($facetValues)
+    #displaySearchFacetValuesForDate($facetValues)
+  #end
+#end
 {{/velocity}}
 
 {{velocity}}
 #if ($xcontext.action == 'get' &amp;&amp; "$!request.facet" != '' &amp;&amp; ($request.startDate || $request.endDate))
   #handleCustomDateInterval()
-#elseif ($facetValues)
-  {{html}}#displaySearchFacetValues_date($facetValues){{/html}}
 #end
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrUserFacet.xml
===================================================================
--- Main/SolrUserFacet.xml	(revision 24079)
+++ Main/SolrUserFacet.xml	(revision 24081)
@@ -122,8 +122,8 @@
 <use>onDemand</use>
 </property>
 </object>
-<content>{{velocity}}
-#macro (displaySearchFacetValue_user $user)
+<content>{{velocity output="false"}}
+#macro (displaySearchFacetValueForUser $user)
   #set ($userReference = $services.model.resolveDocument($user))
   ## The string returned by XWiki#getUserName() is XML encoded.
   #set ($userName = $xwiki.getUserName($user, false))
@@ -142,13 +142,14 @@
     &lt;/span&gt;
   &lt;/span&gt;
 #end
-#if ($facetValues)
-  #set ($discard = $xwiki.ssfx.use('uicomponents/widgets/userpicker/userPicker.css', true))
-  #set ($discard = $xwiki.ssx.use('Main.SolrUserFacet'))
-  {{html}}
-  &lt;ul class="users"&gt;
-    #displaySearchFacetValuesLimited($facetValues {} 'displaySearchFacetValue_user')
-  &lt;/ul&gt;
-  {{/html}}
+
+#macro (displaySearchFacetValues_user $facetValues)
+  #if ($facetValues)
+    #set ($discard = $xwiki.ssfx.use('uicomponents/widgets/userpicker/userPicker.css', true))
+    #set ($discard = $xwiki.ssx.use('Main.SolrUserFacet'))
+    &lt;ul class="users"&gt;
+      #displaySearchFacetValuesLimited($facetValues {} 'displaySearchFacetValueForUser')
+    &lt;/ul&gt;
+  #end
 #end
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrLocaleFacet.xml
===================================================================
--- Main/SolrLocaleFacet.xml	(revision 24079)
+++ Main/SolrLocaleFacet.xml	(revision 24081)
@@ -21,8 +21,8 @@
 <minorEdit>false</minorEdit>
 <syntaxId>xwiki/2.1</syntaxId>
 <hidden>true</hidden>
-<content>{{velocity}}
-#macro (displaySearchFacetValue_locale $facetPrettyValue)
+<content>{{velocity output="false"}}
+#macro (displaySearchFacetValueForLocale $facetPrettyValue)
   #if ($facetValue.name == $facetPrettyValue)
     #set ($locale = $services.localization.toLocale($facetValue.name))
     $escapetool.xml($locale.getDisplayName($currentLocale))
@@ -32,7 +32,10 @@
     &lt;img src="$xwiki.getSkinFile('/icons/silk/information.png')" alt="$hint" title="$hint" class="icon" /&gt;
   #end
 #end
-#set ($currentLocale = $services.localization.currentLocale)
-#retainMatchedRequestValues()
-{{html}}#displaySearchFacetValues($facetValues {} 'displaySearchFacetValue_locale'){{/html}}
+
+#macro (displaySearchFacetValues_locale $facetValues)
+  #set ($currentLocale = $services.localization.currentLocale)
+  #retainMatchedRequestValues()
+  #displaySearchFacetValues($facetValues {} 'displaySearchFacetValueForLocale')
+#end
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrMediaTypeFacet.xml
===================================================================
--- Main/SolrMediaTypeFacet.xml	(revision 24079)
+++ Main/SolrMediaTypeFacet.xml	(revision 24081)
@@ -258,7 +258,7 @@
 </property>
 </object>
 <content>{{velocity output="false"}}
-#macro (displaySearchFacetValues_mediaType $facetValues)
+#macro (displaySearchFacetValuesForMediaType $facetValues)
   #set ($discard = $xwiki.ssx.use('Main.SolrMediaTypeFacet'))
   #set ($discard = $xwiki.jsx.use('Main.SolrMediaTypeFacet'))
   #set ($categoryMap = $solrConfig.facet.mediaType.categories)
@@ -419,10 +419,10 @@
     &lt;span title="$mediaType"&gt;$prettyName&lt;/span&gt;
   #end
 #end
-{{/velocity}}
 
-{{velocity}}
-#if ($facetValues)
-  {{html}}#displaySearchFacetValues_mediaType($facetValues){{/html}}
+#macro (displaySearchFacetValues_mimetype $facetValues)
+  #if ($facetValues)
+    #displaySearchFacetValuesForMediaType($facetValues)
+  #end
 #end
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
Index: Main/SolrTypeFacet.xml
===================================================================
--- Main/SolrTypeFacet.xml	(revision 24079)
+++ Main/SolrTypeFacet.xml	(revision 24081)
@@ -21,10 +21,13 @@
 <minorEdit>false</minorEdit>
 <syntaxId>xwiki/2.1</syntaxId>
 <hidden>true</hidden>
-<content>{{velocity}}
-#macro (displaySearchFacetValue_type $type)
+<content>{{velocity output="false"}}
+#macro (displaySearchFacetValueForType $type)
   $escapetool.xml($services.localization.render("solr.filterBy.type.$type.toLowerCase()"))
 #end
-## We have to reset the sort when the result type selection changes because the sort fields depend on the selected result type.
-{{html}}#displaySearchFacetValues($facetValues {'sort': [], 'sortOrder': []} 'displaySearchFacetValue_type'){{/html}}
+
+#macro (displaySearchFacetValues_type $facetValues)
+  ## We have to reset the sort when the result type selection changes because the sort fields depend on the selected result type.
+  #displaySearchFacetValues($facetValues {'sort': [], 'sortOrder': []} 'displaySearchFacetValueForType')
+#end
 {{/velocity}}</content></xwikidoc>
\ No newline at end of file
