function renderEjs(filename, data, element, callback) {
  $.get(filename)
    .done(function(htmlTmpl) {
      element.html(ejs.render(htmlTmpl, data));
    })
    .fail(function(error) {
      console.log('failed to get html template ' + filename + ': ' + JSON.stringify(error));
      alert('failed to fetch html template ' + filename);
    })
    .always(function () {
      if (typeof callback === 'function') callback();
      resizeApp();
    });
}
Fetch the url give at filename from the server and render the content of this
 template with the data object. Afterwards the rendered html is added at the
 html element given.

@param {string} filename url to retrieve as template
@param {object} data object to use for rendering
@param {object} element jquery html element to attach rendered data to
@param {function} [callback] optional function to call when rendering html is attached to dom