# كيفية الحصول على "string === string" في القالب؟

**URL:** <https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404>\
**Category:** Development\
**Created:** [21 يوليو 2020، 4:11م UTC](https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404 "2020-07-21T16:11:34Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)\
**Post date:** [22 يوليو 2020، 3:28ص UTC](https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404/4 "2020-07-22T03:28:19Z")

</div>

تتضمن قوالب Handlebars منطقًا بوليانيًا بدائيًا فقط. يمكنك إجراء عمليات تحقق من [القيم الحقيقية (truthy values)](https://www.sitepoint.com/javascript-truthy-falsy/) للخاصية.

لتنفيذ أي منطق أكثر تعقيدًا، يجب عليك تنفيذ المنطق في ملف Ember JS المرتبط بالقالب.

على سبيل المثال، إذا كان لديك قالب في `templates/components/my-component.hbs`، فيجب عليك استخدام ملف JS `components/my-component.js` لإجراء الحساب.

في هذا الملف، يمكنك فعل شيء مثل التالي:

```js
import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component";

export default Component.extend({
  @discourseComputed("string1", "string2")
  property(string1, string2) {
    return string1 === string2;
  }
});

```

`property` هو مجرد اسم لدالة، ولكن يمكن أن يكون أي اسم آخر.

ثم في القالب، يمكنك فعل شيء مثل التالي:

```plaintext
{{#if property}}
 blah blah...
{{/if}}

```

هذا يجلب الخاصية المحسوبة من ملف JS ويعرض المحتوى داخل كتلة `#if` فقط إذا كانت `property` تُرجع `true`.

---

_[View the full topic](https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404)._
