               if dependencies = context.shift()
                 options.dependencies = dependencies.split /\s+/
 
-              if eventRegExp.test type
-                type = type.replace eventRegExp, ''
-                options.special = 'event'
-
-              if classRegExp.test type
-                type = type.replace classRegExp, ''
-                options.special = 'class'
-
-              if iterationRegExp.test type
-                type = type.replace iterationRegExp, ''
-                options.special = 'iteration'
-
               binding = new Rivets.Binding node, type, model, keypath, options
               binding.view = @
 
               @bindings.push binding
 
-          if iterator
-            node.removeAttribute(a.name) for a in iterator
-            iterator = null
+        attributes = null if attributes
+
       return
 
     for el in @els
       parseNode el
       parseNode node for node in el.getElementsByTagName '*'
+
     return
 
   # Returns an array of bindings where the supplied function evaluates to true.

    when 'select-multiple' then o.value for o in el when o.selected
    else el.value

# Returns an event binding routine for the specified event.
eventBinding = (event) -> (el, context, bind, unbind) ->
  unbindEvent el, event, unbind if unbind
  bindEvent el, event, bind, context

# Returns a class binding routine for the specified class name.
classBinding = (name) -> (el, value) ->
  elClass = " #{el.className} "
  hasClass = elClass.indexOf(" #{name} ") != -1

  if !value is hasClass
    el.className = if value
      "#{el.className} #{name}"
    else
      elClass.replace(" #{name} ", ' ').trim()

# Returns an iteration binding routine for the specified collection.
iterationBinding = (name) -> (el, collection, binding) ->
  if binding.iterated?
    for iteration in binding.iterated
      iteration.view.unbind()
      iteration.el.parentNode.removeChild iteration.el
  else
    binding.marker = document.createComment " rivets: each-#{name} "
    el.parentNode.insertBefore binding.marker, el
    el.parentNode.removeChild el

  binding.iterated = []

  for item in collection
    data = {}
    data[n] = m for n, m of binding.view.models
    data[name] = item
    itemEl = el.cloneNode true
    previous = binding.iterated[binding.iterated.length - 1] or binding.marker
    binding.marker.parentNode.insertBefore itemEl, previous.nextSibling ? null

    binding.iterated.push
      el: itemEl
      view: rivets.bind itemEl, data

# Returns an attribute binding routine for the specified attribute. This is what
# is used when there are no matching routines for an identifier.
attributeBinding = (attr) -> (el, value) ->
  if value then el.setAttribute attr, value else el.removeAttribute attr

# Core binding routines.
Rivets.routines =
  enabled: (el, value) ->
    el.disabled = !value
  disabled: (el, value) ->
    el.disabled = !!value
  checked: (el, value) ->
    if el.type is 'radio'
      el.checked = el.value is value
    else
      el.checked = !!value
  unchecked: (el, value) ->
    if el.type is 'radio'
      el.checked = el.value isnt value
    else
      el.checked = !value
  show: (el, value) ->
    el.style.display = if value then '' else 'none'
  hide: (el, value) ->
    el.style.display = if value then 'none' else ''
  html:  (el, value) ->
    el.innerHTML = if value? then value else ''
  value: (el, value) ->
    if el.type is 'select-multiple'
      o.selected = o.value in value for o in el if value?
    else
      el.value = if value? then value else ''
  text: (el, value) ->
    if el.innerText?
      el.innerText = if value? then value else ''
    else
      el.textContent = if value? then value else ''

# Default configuration.
Rivets.config =

  # element, the type of binding, the model object and the keypath at which
  # to listen for changes.
  constructor: (@el, @type, @model, @keypath, @options = {}) ->
    unless @binder = Rivets.routines[type]
      for identifier, value of Rivets.routines
        if identifier isnt '*' and identifier.indexOf('*') isnt -1
          regexp = new RegExp "^#{identifier.replace('*', '.+')}$"
          if regexp.test type
            @binder = value
            @args = new RegExp("^#{identifier.replace('*', '(.+)')}$").exec type
            @args.shift()

    @binder or= Rivets.routines['*']

    if @binder instanceof Function
      @binder = {routine: @binder}

    @formatters = @options.formatters || []

  # Applies all the current formatters to the supplied value and returns the
  # formatted value.
