added depth param to recursiveWrite(). depth is also passed to template so it can inject a path to doc root in template