   constructor: (container, @name, options = {}) ->
     @selected = {}
     if not options.template
-      template = '{{#if @index}}' + 
+      template = '{{#if @index}}' +
             '<hr class="df-separator">' +
             '{{/if}}' +
             '<div class="df-facets">'+

      template = options.template

    super(container, template, options)
  
  init: (controller) ->
    super(controller)
    _this = this
    
    # Clean selected  terms when new search
    @bind "df:search", (params) ->  
      _this.selected = {}

    # The filtering by click
    $(@container).on 'click', "a[data-facet='#{@name}']", (e) ->
        e.preventDefault()
        termFacet = $(this)
        value = termFacet.data "value" 
        key = termFacet.data "facet"

        if _this.selected[value]
            _this.controller.removeFilter key, value
        
        else
            _this.controller.addFilter key, value
        
        _this.controller.refresh()

    # Removes filters not present in results.


  renderNext: () ->

module.exports = TermFacet
