lib/mixins/view.js
function (structure, locals) {
      if (typeof structure !== 'string') {
        locals = structure;
        structure = null;
      }

      var self = this;

      var data = {};
      lazy.extend(data, this);
      lazy.extend(data, this.parsePath());
      lazy.extend(data, this.context(locals));
      this.data.dest = this.data.dest || {};

      var opts = lazy.get(data, 'permalinks') || {};
      lazy.extend(opts, this.options.permalinks || {});

      if (typeof structure !== 'string') {
        structure = opts.structure || ':path';
      }

      return structure.replace(/:(\w+)(?:\((.*)\))?/g, function (m, param, prop) {
        var res = data[param] || param;
        if (typeof res === 'function' && prop) {
          return res.call(data, prop);
        }

        self.data.dest = res;
        return res;
      });
    }
function (structure, locals) {
      if (typeof structure !== 'string') {
        locals = structure;
        structure = null;
      }

      var self = this;

      var data = {};
      lazy.extend(data, this);
      lazy.extend(data, this.parsePath());
      lazy.extend(data, this.context(locals));
      this.data.dest = this.data.dest || {};

      var opts = lazy.get(data, 'permalinks') || {};
      lazy.extend(opts, this.options.permalinks || {});

      if (typeof structure !== 'string') {
        structure = opts.structure || ':path';
      }

      return structure.replace(/:(\w+)(?:\((.*)\))?/g, function (m, param, prop) {
        var res = data[param] || param;
        if (typeof res === 'function' && prop) {
          return res.call(data, prop);
        }

        self.data.dest = res;
        return res;
      });
    }
function ( structure , locals ) { if ( typeof structure !== 'string' ) { locals = structure ; structure = null ; } var self = this ; var data = { } ; lazy . extend ( data , this ) ; lazy . extend ( data , this . parsePath ( ) ) ; lazy . extend ( data , this . context ( locals ) ) ; this . data . dest = this . data . dest || { } ; var opts = lazy . get ( data , 'permalinks' ) || { } ; lazy . extend ( opts , this . options . permalinks || { } ) ; if ( typeof structure !== 'string' ) { structure = opts . structure || ':path' ; } return structure . replace ( / :(\w+)(?:\((.*)\))? / g , function ( m , param , prop ) { var res = data [ param ] || param ; if ( typeof res === 'function' && prop ) { return res . call ( data , prop ) ; } self . data . dest = res ; return res ; } ) ; }
Generate a permalink for a view.

```js
app.posts.get('foo.md')
.render(function (err, res) {
dest(res.permalink(), res);
//=>
});
```
@param  {Object} `locals` pass any additional locals for context.
@return {String} Returns a permalink string.
@api public
Generate a permalink for a view .