mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	templates: Simplify nested Handlebars conditionals using {{else if}}.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							2e2cd3eb49
						
					
				
				
					commit
					706d96b22e
				
			@@ -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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -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"> :{{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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,13 +12,11 @@
 | 
			
		||||
        <button type="button" class="button no-style user-status-value">
 | 
			
		||||
            {{#if emoji.emoji_alt_code}}
 | 
			
		||||
                <div class="emoji_alt_code"> :{{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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -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">
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,11 @@
 | 
			
		||||
{{#if selected_emoji}}
 | 
			
		||||
    {{#if selected_emoji.emoji_alt_code}}
 | 
			
		||||
        <div class="emoji_alt_code"> :{{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}}
 | 
			
		||||
 
 | 
			
		||||
@@ -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"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,7 @@
 | 
			
		||||
        <span class='emoji emoji-{{ emoji_code }}'></span>
 | 
			
		||||
    {{/if}}
 | 
			
		||||
      
 | 
			
		||||
{{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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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"> :{{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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user