1
Ich versuche, eine Logik zu machen, wenn die Bedingung mit den Handles mit Or || aber es funktioniert nicht. wie das || funktioniert im Lenker.ifCond mit Lenker js
<img src="{{#ifCond item.0.img_url '!==' '' || item.0.img_url '!==' null }}
{{item.0.img_url}}{{else}}/assets/images/logo.svg{{/ifCond}}">
Ich bin mit dieser Helferfunktion
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '!=':
return (v1 != v2) ? options.fn(this) : options.inverse(this);
case '!==':
return (v1 !== v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
});
ich es so, dass für jetzt getan haben, aber ich weiß nicht, ob dies der richtige Weg ist, es zu tun oder nicht.
{{#ifCond item.0.img_url '!==' ''}}
{{item.0.img_url}}
{{#ifCond item.0.img_url '!==' null}}
{{item.0.img_url}}
{{else}}
/assets/images/logo.svg
{{/ifCond}}
{{else}}
/assets/images/logo.svg
{{/ifCond}}