   return @getData().columns or false
 
 # #### `table_template` String ( optional )
-#   The name of table layout template that you want to render.
-#   default is `default_table_template` found [here](lib/datatables.html)
-#   You can set your default template by assigning the template name to `Template.datatable.defaultTemplate`
+# The name of table layout template that you want to render.
+# Default is `default_table_template` found [here](lib/datatables.html).
+# You can set your default template by assigning the template name to `Template.datatable.defaultTemplate`.
 
 # ##### Default Table Template
-#   The default table template is defined in datatables.html
+# The default table template is defined in datatables.html.
 Template.dataTable.defaultTemplate = 'default_table_template'
 
 # ##### chooseTemplate Helper
-#   Return the template specified in the component parameters
-#   Set table template to default if no template name is passed in
-#   If the template is defined return it
-#   Otherwise return the default template
+# Return the template specified in the component parameters
 Template.dataTable.chooseTemplate = ( table_template = null ) ->
+  # Set table template to default if no template name is passed in
   table_template ?= Template.dataTable.defaultTemplate
+  # If the template is defined return it
   if Template[ table_template ]
     return Template[ table_template ]
+  # Otherwise return the default template
   else return Template[ @defaultTemplate ]
 
 
 # #### `collection` Meteor Collection ( required )
-#   This is the collection that house the documents your datatable is displaying
-#   This collection must be defined on both the client and the server
+# This is the collection that houses the documents your datatable is displaying
+# and must be defined on both the client and the server.
 Template.dataTable.setCollection = ( collection ) ->
   Match.test collection, Object
   @setData 'collection', collection

  else return @getData().rows or false

# ##### getRowIndex()
#   gets the datatable index of a row by mongo id
Template.dataTable.getRowIndex = ( _id ) ->
  index = false
  counter = 0

  return @getData().options or @presetOptions() or false

# ##### prepareOptions()
# Prepares the datatable options object by merging the options passed in with the defaults.
Template.dataTable.prepareOptions = ->
  options = @getOptions() or {}
  options.aaData = @getRows() or []
  options.aoColumns = @getColumns() or []
  # If the componet was declared with a collection and a query it is setup as a reactive datatable.
  if @getCollection() and @getQuery()
    options.bServerSide = true
    options.bProcessing = true
    # `options.sAjaxSource` is currently useless, but is passed into `fnServerData` by datatables.
    options.sAjaxSource = "useful?"
    # This binds the datatables `fnServerData` server callback to this component instance.
    # `_.debounce` is used to prevent unneccesary subcription calls while typing a search
    options.fnServerData = _.debounce( @fnServerData.bind( @ ), 300 )
  @setOptions _.defaults( options, @defaultOptions )

# #### `selector` String ( required )
# The table selector for the dataTable instance you are creating, must be unique in the page scope or you will get
# datatable mulit-render error.
Template.dataTable.setSelector = ( selector ) ->
  Match.test selector, String
  @setData 'selector', selector
