docs: function(view) {
      if (view.options.layoutApplied) {
        return view;
      }
  
      // handle pre-layout middleware
      this.handle('preLayout', view);
  
      var opts = {};
      lazy.extend(opts, this.options);
      lazy.extend(opts, view.options);
      lazy.extend(opts, view.context());
  
      // get the layout stack
      var stack = {};
      var alias = this.viewTypes.layout;
      var len = alias.length, i = 0;
  
      while (len--) {
        var views = this.views[alias[i++]];
        for (var key in views) {
          var val = views[key];
          if (views.hasOwnProperty(key) && typeof val !== 'function' && val.path) {
            stack[key] = val;
          }
        }
      }
  
      // get the name of the first layout
      var name = view.layout;
      var str = view.content;
      var self = this;
  
      if (!name) return view;
  
      // Handle each layout before it's applied to a view
      function handleLayout(layoutObj) {
        view.currentLayout = layoutObj.layout;
        self.handle('onLayout', view);
        delete view.currentLayout;
      }
  
      // actually apply the layout
      var res = lazy.layouts(str, name, stack, opts, handleLayout);
  
      view.option('layoutStack', res.history);
      view.option('layoutApplied', true);
      view.content = res.result;
  
      // handle post-layout middleware
      this.handle('postLayout', view);
      return view;
    }