Render template by name into string

Snippet from here:

function templateToString(template) {
  var View = Ember.View.create({ template: template });
  var buffer = new Ember.RenderBuffer();

  view.render(buffer)

  return buffer.string();
}