if statement - Ember/Handlebars: compare variable with string -


i need display block depending on current views variable in comparison string:

pseudo code is:

{{#if view.somevariable "desiredvalue"}}     hurray desiredvalue exists in  view! {{else}}     sorry, doesn't match... {{/if}} 

of course doesn't work if statement allows 1 param. tried custom registerhelper of handlebars, doesn't resolve view.somevariable, instead uses string (although view.somevariable defined , has value).

finally tried handlebar's registerboundhelper - resolves params doesn't support handlebar's blocks, what's more tries resolve string object, fail again. pure madness!

my views dynamical depends on many factors backend , approach pseudo code perfect resolving it. there way that?

edit: there sample of want ... http://jsfiddle.net/biesior/dms2d/ looks quite trivial...

[if] statement inside each pseudo code of course

you can declare computed property, isdesired on view, compare somevariable string:

app.myview = ember.view.extend({   // ...stuff...   isdesired: ember.computed.equal('somevariable', 'desiredvalue') }); 

and have simple conditional in template:

{{#if view.isdesired}}   hurray desiredvalue exists in view! {{else}}   sorry, doesn't match... {{/if}} 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -