             # the next time a linked template is invoked it will use
             # automagicly the new data because elem doesn't change.
             elem.data = @compile opts.select?.call this
-            @write(opts.dest, elem.data, done)
+            @write(opts.path, opts.dest, elem.data, done)
 
         # do an auto load if not loaded so an extra load call is not needed
         @load opts.src, reload  if opts.src? and not (@loading or @loaded)

fs = require 'fs'
mkdirp = require 'mkdirp'
jQuery = require 'jquery'
{ extname, dirname } = require 'path'
{ jsonify } = require './traverse'
link = require './linker'


        unless @extensions[ext]?
            return done new Error "file extension of #{dest} not supported."
        source = @extensions[ext](data)
        fullpath = pathjoin(path, dest)
        mkdirp dirname(fullpath), (err) ->
            return done err if err
            fs.writeFile(fullpath, source, done)

    parse: (data) ->
        @el = @$(data)
