Boolesche Logik innerhalb einer LENKER-Vorlage

Ist es möglich, führen Sie Boolesche Logik innerhalb eines Lenkers abhängt?

Ich jetzt spoof dieses Verhalten mit einer controller-Funktion, so dass ich am Ende mit dem controller

App.ApplicationController = Ember.Controller.extend({
    bool1: true,
    bool2: true,
    both: function(){ return this.bool1 && this.bool2; }.property('content.both'),
});

Die es mir erlaubt die Verwendung einer LENKER-Vorlage von

<script type="text/x-handlebars">
  {{#if both}}
     <p> both were true </p>
  {{/if}}
</script>

und das funktioniert gut, wirft aber einige Probleme. First off, es verschleiert, was passiert (besonders, wenn gute Funktionsnamen nicht verwendet werden). Zweitens scheint es zu verletzen ein wenig auf das MVC-Trennung.

Ist es möglich zu tun, etwas entlang der Linien von

<script type="text/x-handlebars">
  {{#if bool1 && bool2}}  <!-- this will not actually work -->
     <p> both were true </p>
  {{/if}}
</script>

haben und es funktioniert?

InformationsquelleAutor BostonJohn | 2013-02-12

Schreibe einen Kommentar