Question

I am following a template for dynamically choosing which model, route, controller to render with a render helper, as outlined in this question (and elsewhere). My problem is that we want to run with the Ember.ENV.RAISE_ON_DEPRECATION flag set, to catch problems before they develop into upgrade nightmares. I am calling Ember.Render from a handlebars helper, like this:

Ember.Handlebars.registerBoundHelper('renderModuleEdit', function(callingContext, module, options) {
  var modelName = callingContext.get('type').get('modelName');
  return Ember.Handlebars.helpers.render.call(callingContext, "edit_" + modelName, modelName, options);
});

The template has this code in it:

{{#each module in modules}}
  <div class="tab-content" {{bind-attr class="module.active:active"}}>
    {{renderModuleEdit module module}}
  </div>
{{/each}}

The problem is that render fails on the test for 'quoteless parameters', even though I'm using call() on it, rather than a direct handlebars template syntax. The test is defined in the source on this line. The actual test is options.types[0] !== 'ID', and while the options parameter is available in the register helper function (first code block above), and thus I would be able to change the 1st type away from 'ID', I'm not sure what I can change it to that wouldn't cause something else to subtly break later. The error message comes through as:

Uncaught Error: Using a quoteless parameter with {{render}} is deprecated. Please update to quoted usage '{{render "edit_Intro"}}.

As I am not using {{render edit_Intro}} to make this call, I have no idea how to correct this. If I change the template code to {{renderModuleEdit 'module' 'module'}}, then the parameters to my renderModuleEdit come through as strings of 'module' rather than the model instance I need.

I feel like I have no understanding of what this test is actually for and what the 'quoteless' vs 'quoted' parameters even mean. Can someone explain this? Is there a way around this deprecation warning for calling render from a registered bound handlebars helper like this?

Was it helpful?

Solution

A dirty solution, but working for now:

Ember.Handlebars.registerBoundHelper('renderModuleEdit', function(callingContext, module, options) {
  options.types[0] = "STRING";  // FIXME: hack

  var modelName = callingContext.get('type').get('modelName');
  return Ember.Handlebars.helpers.render.call(callingContext, "edit_" + modelName,     modelName, options);
});

I also, wasn't able to find a proper fix yet :-/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top