benchmarks/scenarios/ember.js
function wrap(template) {
    if (template === null) {
      return null;
    }

    return {
      meta: template.meta,
      arity: template.arity,
      raw: template,
      render: function (self, env, options, blockArguments) {
        var scope = env.hooks.createFreshScope();

        var contextualElement = options && options.contextualElement;
        var renderOptions = new _htmlbarsRuntimeRender.RenderOptions(null, self, blockArguments, contextualElement);

        return _htmlbarsRuntimeRender.default(template, env, scope, renderOptions);
      }
    };
  }
function wrap(template) {
    if (template === null) {
      return null;
    }

    return {
      meta: template.meta,
      arity: template.arity,
      raw: template,
      render: function (self, env, options, blockArguments) {
        var scope = env.hooks.createFreshScope();

        var contextualElement = options && options.contextualElement;
        var renderOptions = new _htmlbarsRuntimeRender.RenderOptions(null, self, blockArguments, contextualElement);

        return _htmlbarsRuntimeRender.default(template, env, scope, renderOptions);
      }
    };
  }
function wrap ( template ) { if ( template === null ) { return null ; } return { meta : template . meta , arity : template . arity , raw : template , render : function ( self , env , options , blockArguments ) { var scope = env . hooks . createFreshScope ( ) ; var contextualElement = options && options . contextualElement ; var renderOptions = new _htmlbarsRuntimeRender . RenderOptions ( null , self , blockArguments , contextualElement ) ; return _htmlbarsRuntimeRender . default ( template , env , scope , renderOptions ) ; } } ; }
HTMLBars delegates the runtime behavior of a template to
hooks provided by the host environment. These hooks explain
the lexical environment of a Handlebars template, the internal
representation of references, and the interaction between an
HTMLBars template and the DOM it is managing.

While HTMLBars host hooks have access to all of this internal
machinery, templates and helpers have access to the abstraction
provided by the host hooks.

## The Lexical Environment

The default lexical environment of an HTMLBars template includes:

Any local variables, provided by *block arguments*
The current value of `self`

## Simple Nesting

Let's look at a simple template with a nested block:

```hbs
<h1>{{title}}</h1>

{{#if author}}
<p class="byline">{{author}}</p>
{{/if}}
```

In this case, the lexical environment at the top-level of the
template does not change inside of the `if` block. This is
achieved via an implementation of `if` that looks like this:

```js
registerHelper('if', function(params) {
if (!!params[0]) {
return this.yield();
}
});
```

A call to `this.yield` invokes the child template using the
current lexical environment.

## Block Arguments

It is possible for nested blocks to introduce new local
variables:

```hbs
{{#count-calls as |i|}}
<h1>{{title}}</h1>
<p>Called {{i}} times</p>
{{/count}}
```

In this example, the child block inherits its surrounding
lexical environment, but augments it with a single new
variable binding.

The implementation of `count-calls` supplies the value of
`i`, but does not otherwise alter the environment:

```js
var count = 0;
registerHelper('count-calls', function() {
return this.yield([ ++count ]);
});
```
HTMLBars delegates the runtime behavior of a template to hooks provided by the host environment . These hooks explain the lexical environment of a Handlebars template the internal representation of references and the interaction between an HTMLBars template and the DOM it is managing .