templates: Simplify nested Handlebars conditionals using {{else if}}.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-06-29 15:14:58 -07:00
committed by Tim Abbott
parent 2e2cd3eb49
commit 706d96b22e
13 changed files with 41 additions and 65 deletions

View File

@@ -2,8 +2,7 @@
<div class="message_edit_notice auto-select" title="{{#tr}}Edited ({last_edit_timestr}){{/tr}}">
{{t "SAVING" }}
</div>
{{else}}
{{#if moved}}
{{else if moved}}
<div class="message_edit_notice auto-select" title="{{#tr}}Moved ({last_edit_timestr}){{/tr}}">
{{t "MOVED" }}
</div>
@@ -12,4 +11,3 @@
{{t "EDITED" }}
</div>
{{/if}}
{{/if}}

View File

@@ -1,5 +1,5 @@
{{#with emoji_dict}}
<div class="emoji-popover-emoji {{#if ../message_id }}{{#if has_reacted}} reacted {{/if}} reaction {{else}} {{#if ../is_status_emoji_popover}} status_emoji {{else}} composition {{/if}} {{/if}}" data-emoji-name="{{name}}" tabindex="0" data-emoji-id="{{../type}},{{../section}},{{../index}}">
<div class="emoji-popover-emoji {{#if ../message_id }}{{#if has_reacted}} reacted {{/if}} reaction {{else if ../is_status_emoji_popover}} status_emoji {{else}} composition {{/if}}" data-emoji-name="{{name}}" tabindex="0" data-emoji-id="{{../type}},{{../section}},{{../index}}">
{{#if is_realm_emoji}}
<img src="{{url}}" class="emoji"/>
{{else}}

View File

@@ -1,12 +1,10 @@
<div class="{{this.class}}" aria-label="{{this.label}}" data-reaction-id="{{this.local_id}}">
{{#if this.emoji_alt_code}}
<div class="emoji_alt_code">&nbsp:{{this.emoji_name}}:</div>
{{else}}
{{#if this.is_realm_emoji}}
{{else if this.is_realm_emoji}}
<img src="{{this.url}}" class="emoji" />
{{else}}
<div class="emoji emoji-{{this.emoji_code}}"></div>
{{/if}}
{{/if}}
<div class="message_reaction_count">{{this.count}}</div>
</div>

View File

@@ -51,11 +51,9 @@
{{! edit topic pencil icon }}
{{#if always_visible_topic_edit}}
<i class="fa fa-pencil always_visible_topic_edit recipient_bar_icon hidden-for-spectators" {{#unless realm_allow_message_editing}}style="display: none"{{/unless}} data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>
{{else}}
{{#if on_hover_topic_edit}}
{{else if on_hover_topic_edit}}
<i class="fa fa-pencil on_hover_topic_edit recipient_bar_icon hidden-for-spectators" {{#unless realm_allow_message_editing}}style="display: none"{{/unless}} data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>
{{/if}}
{{/if}}
{{#if user_can_resolve_topic}}
{{#if topic_is_resolved}}

View File

@@ -12,13 +12,11 @@
<button type="button" class="button no-style user-status-value">
{{#if emoji.emoji_alt_code}}
<div class="emoji_alt_code">&nbsp:{{emoji.emoji_name}}:</div>
{{else}}
{{#if emoji.url}}
{{else if emoji.url}}
<img src="{{emoji.url}}" class="emoji status_emoji" />
{{else}}
<div class="emoji status_emoji emoji-{{emoji.emoji_code}}"></div>
{{/if}}
{{/if}}
{{status_text}}
</button>
{{/each}}

View File

@@ -1,7 +1,6 @@
{{#if is_guest}}
<div class='tip'>{{t "Guests cannot edit custom emoji." }}</div>
{{else}}
{{#if (eq realm_add_custom_emoji_policy policy_values.by_admins_only.code) }}
{{else if (eq realm_add_custom_emoji_policy policy_values.by_admins_only.code) }}
<div class='tip'>{{t "Only organization administrators can add custom emoji in this organization." }}</div>
{{else if (eq realm_add_custom_emoji_policy policy_values.by_moderators_only.code)}}
<div class='tip'>{{t 'Only organization administrators and moderators can add custom emoji in this organization.'}}</div>
@@ -10,4 +9,3 @@
{{else}}
<div class='tip'>{{t "Any member of this organization can add custom emoji." }}</div>
{{/if}}
{{/if}}

View File

@@ -88,11 +88,9 @@
<div class="text">{{t "Custom emoji" }}</div>
{{#if is_guest}}
<i class="locked fa fa-lock" title="{{t 'Guest users cannot edit custom emoji.' }}"></i>
{{else}}
{{#if show_emoji_settings_lock}}
{{else if show_emoji_settings_lock}}
<i class="locked fa fa-lock" title="{{t 'Only organization administrators can edit these settings.'}}"></i>
{{/if}}
{{/if}}
</li>
{{#unless is_guest}}
<li tabindex="0" data-section="user-groups-admin">

View File

@@ -1,13 +1,11 @@
{{#if selected_emoji}}
{{#if selected_emoji.emoji_alt_code}}
<div class="emoji_alt_code">&nbsp:{{selected_emoji.emoji_name}}:</div>
{{else}}
{{#if selected_emoji.url}}
{{else if selected_emoji.url}}
<img src="{{selected_emoji.url}}" class="emoji selected_emoji" />
{{else}}
<div class="emoji selected_emoji emoji-{{selected_emoji.emoji_code}}"></div>
{{/if}}
{{/if}}
{{else}}
<a type="button" class="smiley_icon show fa fa-smile-o"></a>
{{/if}}

View File

@@ -1,8 +1,8 @@
{{!-- If setting is disabled on realm level, then render setting as control-label-disabled and do not set setting value. Setting status should not change on any click handler, as it is disabled at realm level. --}}
<div id="sub_{{setting_name}}_setting"
class="sub_setting_checkbox
{{#if disabled_realm_setting}}control-label-disabled{{else}}
{{#if notification_setting}}sub_notification_setting {{#if is_muted}}muted-sub{{/if}}{{/if}}{{/if}} new-style">
{{#if disabled_realm_setting}}control-label-disabled
{{else if notification_setting}}sub_notification_setting {{#if is_muted}}muted-sub{{/if}}{{/if}} new-style">
<label class="checkbox">
<input id="{{setting_name}}_{{stream_id}}" name="{{setting_name}}"
class="sub_setting_control" type="checkbox"

View File

@@ -5,8 +5,7 @@
<span class='emoji emoji-{{ emoji_code }}'></span>
{{/if}}
&nbsp;&nbsp;
{{else}}
{{#if is_person}}
{{else if is_person}}
{{#if user_circle_class}}
<span class="{{user_circle_class}} user_circle"></span>
{{/if}}
@@ -15,12 +14,9 @@
{{else}}
<span class='typeahead-image fa fa-bullhorn no-presence-circle'></span>
{{/if}}
{{else}}
{{#if is_user_group}}
{{else if is_user_group}}
<i class="typeahead-image icon fa fa-group no-presence-circle" aria-hidden="true"></i>
{{/if}}
{{/if}}
{{/if}}
<strong>
{{~ primary ~}}
</strong>

View File

@@ -35,13 +35,11 @@
{{bot_owner.full_name}}
</span>
</li>
{{else}}
{{#if is_system_bot}}
{{else if is_system_bot}}
<li>{{#tr}}System bot{{/tr}}</li>
{{else}}
<li>{{#tr}}Bot{{/tr}}</li>
{{/if}}
{{/if}}
{{else}}
<li>{{ user_type }}</li>
{{/if}}
@@ -88,14 +86,12 @@
{{#if status_emoji_info}}
{{#if status_emoji_info.emoji_alt_code}}
<div class="emoji_alt_code">&nbsp:{{status_emoji_info.emoji_name}}:</div>
{{else}}
{{#if status_emoji_info.url}}
{{else if status_emoji_info.url}}
<img src="{{status_emoji_info.url}}" class="emoji status_emoji" />
{{else}}
<div class="emoji status_emoji emoji-{{status_emoji_info.emoji_code}}"></div>
{{/if}}
{{/if}}
{{/if}}
{{status_text}}
{{#if is_me}}(<a tabindex="0" class="clear_status">{{#tr}}clear{{/tr}}</a>){{/if}}
</span>

View File

@@ -56,13 +56,11 @@
<a href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>
{{else if this.is_external_account}}
<a href="{{this.link}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>
{{else}}
{{#if this.rendered_value}}
{{else if this.rendered_value}}
<div class="value rendered_markdown">{{rendered_markdown this.rendered_value}}</div>
{{else}}
<div class="value">{{this.value}}</div>
{{/if}}
{{/if}}
</div>
{{/each}}
</div>