index.js
function(view, locals, isAsync) {
    if (typeof locals === 'boolean') {
      isAsync = locals;
      locals = {};
    }

    // get the engine to use
    locals = locals || {};
    var engine = this.engine(locals.engine ? locals.engine : view.engine);

    if (typeof engine === 'undefined') {
      throw this.error('compile', 'engine', view);
    }
    if (!engine.hasOwnProperty('compile')) {
      throw this.error('compile', 'method', engine);
    }

    view.ctx('compile', locals);
    // build the context to pass to the engine
    var ctx = view.context(locals);
    // apply layout
    view = this.applyLayout(view, ctx);
    // handle `preCompile` middleware
    this.handleView('preCompile', view, locals);

    // Bind context to helpers before passing to the engine.
    this.bindHelpers(view, locals, ctx, (locals.async = isAsync));
    var settings = lazy.extend({}, ctx, locals);

    // compile the string
    view.fn = engine.compile(view.content, settings);
    // handle `postCompile` middleware
    this.handleView('postCompile', view, locals);
    return view;
  }
function(view, locals, isAsync) {
    if (typeof locals === 'boolean') {
      isAsync = locals;
      locals = {};
    }

    // get the engine to use
    locals = locals || {};
    var engine = this.engine(locals.engine ? locals.engine : view.engine);

    if (typeof engine === 'undefined') {
      throw this.error('compile', 'engine', view);
    }
    if (!engine.hasOwnProperty('compile')) {
      throw this.error('compile', 'method', engine);
    }

    view.ctx('compile', locals);
    // build the context to pass to the engine
    var ctx = view.context(locals);
    // apply layout
    view = this.applyLayout(view, ctx);
    // handle `preCompile` middleware
    this.handleView('preCompile', view, locals);

    // Bind context to helpers before passing to the engine.
    this.bindHelpers(view, locals, ctx, (locals.async = isAsync));
    var settings = lazy.extend({}, ctx, locals);

    // compile the string
    view.fn = engine.compile(view.content, settings);
    // handle `postCompile` middleware
    this.handleView('postCompile', view, locals);
    return view;
  }
function ( view , locals , isAsync ) { if ( typeof locals === 'boolean' ) { isAsync = locals ; locals = { } ; } // get the engine to use locals = locals || { } ; var engine = this . engine ( locals . engine ? locals . engine : view . engine ) ; if ( typeof engine === 'undefined' ) { throw this . error ( 'compile' , 'engine' , view ) ; } if ( ! engine . hasOwnProperty ( 'compile' ) ) { throw this . error ( 'compile' , 'method' , engine ) ; } view . ctx ( 'compile' , locals ) ; // build the context to pass to the engine var ctx = view . context ( locals ) ; // apply layout view = this . applyLayout ( view , ctx ) ; // handle `preCompile` middleware this . handleView ( 'preCompile' , view , locals ) ; // Bind context to helpers before passing to the engine. this . bindHelpers ( view , locals , ctx , ( locals . async = isAsync ) ) ; var settings = lazy . extend ( { } , ctx , locals ) ; // compile the string view . fn = engine . compile ( view . content , settings ) ; // handle `postCompile` middleware this . handleView ( 'postCompile' , view , locals ) ; return view ; }
Compile `content` with the given `locals`.

```js
var blogPost = app.post('2015-09-01-foo-bar');
var view = app.compile(blogPost);
// view.fn => [function]
```

@name .compile
@param  {Object|String} `view` View object.
@param  {Object} `locals`
@param  {Boolean} `isAsync` Load async helpers
@return {Object} View object with `fn` property with the compiled function.
@api public
Compile content with the given locals .