1

Hey so my problem is probably simple as I am brand new to ember and ember-cli, from what I understand you simply edit an applications HBS template containing the html, IE. app/templates/settings.hbs

however my problem is that when I edit one of these files and restart the entire stack, no change is reflected - furthermore I'm basically just trying to create some minor changes to an already created stack by entering an if conditional to find the controller name and display content if it matches what im looking for,

for example

{{#if controller.name == "settings"}}
// diff lis
{else}
// normal lis
{#endif}

most importantly here, any changes I make at all to the HBS template does not seem to be reflected live, any idea why?

Kalman
  • 8,001
  • 1
  • 27
  • 45
Vince Kuro
  • 11
  • 1

2 Answers2

1

In addition to @Oren answer, if you're using ember 1.10 you can take advantage of handlebars subexpressions and write your own eq helper which could be used in more situations. For instance:

Ember.Handlebars.registerBoundHelper('eq', function(left, right) {
  return left === right;
});

And then in your template

{{#if (eq name "settings") }}
  // diff lis
{{else}}
  // normal lis
{{/if}}
// ...
{{#if (eq something otherstuff) }}
  // show this
{{else}}
  // show that
{{/if}}

Live sample http://emberjs.jsbin.com/mezoxiqavi/1/edit

Marcio Junior
  • 19,078
  • 4
  • 44
  • 47
0

Handlebars does not have an equality helper in the form that you have posted. (See this list for a list of all of the built in helpers.)

Instead, what you need to do to make your code work is create a property on your controller:

IsNameSettings: function(){
    return this.get('model.name') === 'settings';
}.property('model.name');

And change your template to use this property (note that you also have {{/endif}} which needs to be changed to {{/if}} [see the link above]):

{{#if controller.IsNameSettings}}
// diff lis
{else}
// normal lis
{/if}

See whether after changing your handlebars template to valid syntax as I described results in the page live updating when you are waiting for a live reload. Confirm that after saving these changes, you see output from ember-cli indicating a successful build. Check for output in the terminal along the lines of:

version: 0.1.12
Livereload server on port 35729
Serving on http://0.0.0.0:4200/

Build successful - 8891ms.
Kalman
  • 8,001
  • 1
  • 27
  • 45
Oren Hizkiya
  • 4,420
  • 2
  • 23
  • 33