Guide

How to Use Conditional Fields to Show and Hide Signature Elements

Lastline Team6 min read
Share

Employee records often lack an optional mobile number, title, or department. Conditional fields hide the matching signature element when its source data is empty, preventing blank rows and stray icons.

The Problem with Empty Fields

Imagine a signature template that includes a phone number row. If an employee doesn't have a phone number on file, a naive template would render something like:

John Smith

Marketing Manager

(blank)

john@acme.com

That blank row with a lonely phone icon looks unprofessional. Multiply this across employees with different missing fields, and the template produces a different set of gaps for each person.

How Conditional Comments Work

Lastline uses a simple HTML comment syntax to conditionally show or hide parts of your signature. Wrap any section of your signature template with a pair of conditional comments, and Lastline will automatically remove that section when the field is empty.

Use this syntax:

<!--[if FIELD_NAME]-->
  <!-- your HTML here -->
<!--[/if FIELD_NAME]-->

When Lastline renders the signature for a specific employee:

  • If the field has a value, the conditional comments are stripped away and the content is displayed normally.
  • If the field is empty or null, Lastline removes the entire block, including the HTML inside it.

Supported Fields

You can use conditional comments with any placeholder field in your signature template. The most commonly used fields include:

{{PHONE}}{{MOBILE}}{{TITLE}}{{DEPARTMENT}}{{COMPANY}}{{WEBSITE}}

You can also wrap a custom placeholder, such as {{LINKEDIN}} or {{FAX}}, with conditional comments.

Practical Examples

Hide a phone number row

Wrap the entire table row so it disappears when the employee has no phone number:

<!--[if PHONE]-->
<tr>
  <td><img src="phone-icon.png" alt="Phone" /></td>
  <td><a href="tel:{{PHONE}}">{{PHONE}}</a></td>
</tr>
<!--[/if PHONE]-->

Hide a mobile number row

<!--[if MOBILE]-->
<tr>
  <td><img src="mobile-icon.png" alt="Mobile" /></td>
  <td><a href="tel:{{MOBILE}}">{{MOBILE}}</a></td>
</tr>
<!--[/if MOBILE]-->

Hide a job title

Use this when an employee record has no title:

<!--[if TITLE]-->
<p style="color: #666; font-size: 14px;">{{TITLE}}</p>
<!--[/if TITLE]-->

Hide a department line

<!--[if DEPARTMENT]-->
<p style="color: #999; font-size: 12px;">{{DEPARTMENT}}</p>
<!--[/if DEPARTMENT]-->

Hide a website link

<!--[if WEBSITE]-->
<tr>
  <td><img src="website-icon.png" alt="Website" /></td>
  <td><a href="{{WEBSITE}}">{{WEBSITE}}</a></td>
</tr>
<!--[/if WEBSITE]-->

Manage every signature from one dashboard.

Connect Google Workspace, assign a template, and deploy it across your team.

Start free

Combining Multiple Conditions

You can use multiple conditional blocks in the same template. Each condition is evaluated independently. Here's a realistic signature template with several conditional fields:

<table>
  <tr>
    <td>
      <strong>{{FULL_NAME}}</strong><br/>

      <!--[if TITLE]-->
      <span style="color: #666;">{{TITLE}}</span><br/>
      <!--[/if TITLE]-->

      <!--[if DEPARTMENT]-->
      <span style="color: #999;">{{DEPARTMENT}}</span><br/>
      <!--[/if DEPARTMENT]-->
    </td>
  </tr>
  <tr>
    <td>
      <!--[if PHONE]-->
      <a href="tel:{{PHONE}}">{{PHONE}}</a><br/>
      <!--[/if PHONE]-->

      <!--[if MOBILE]-->
      <a href="tel:{{MOBILE}}">{{MOBILE}}</a><br/>
      <!--[/if MOBILE]-->

      <!--[if WEBSITE]-->
      <a href="{{WEBSITE}}">{{WEBSITE}}</a>
      <!--[/if WEBSITE]-->
    </td>
  </tr>
</table>

An employee with all fields populated sees the full signature. An employee with only a name and email sees a clean, compact signature with no gaps or blank rows.

Before and After

Here's what the difference looks like for an employee who has no phone number and no department:

Without conditional fields

Sarah Johnson

(empty title line)

(empty department line)

sarah@acme.com

(empty phone line)

With conditional fields

Sarah Johnson

sarah@acme.com

The conditional version removes all three empty rows.

Best Practices

  • Wrap the entire visual element Include the full table row, paragraph, or container in the conditional block. Don't wrap just the placeholder text, or you'll be left with empty icons and labels.
  • Match the field name exactly The field name in <!--[if PHONE]--> must match the placeholder {{PHONE}} exactly (case-sensitive).
  • Always close your conditions Every <!--[if FIELD]--> needs a matching <!--[/if FIELD]-->. Unclosed conditions may cause unexpected rendering.
  • Test with sparse employee data Preview your signature using an employee who has minimal data filled in. This helps you catch layout issues early.
  • Keep required fields unwrapped Fields like name and email that every employee will have don't need conditional comments. Only wrap optional fields.

Conditional fields work with all Lastline signature templates, including custom HTML templates. They're evaluated at render time . Lastline evaluates them separately for each employee at render time.

Common Use Cases

  • New hires They may not have a title, department, or direct phone number yet. Conditional fields keep their signature clean until their profile is complete.
  • Multi-country teams Regions may use different contact fields. Some offices might not have a fax number or landline, while others do.
  • Partial Google Workspace sync If your Google Workspace directory has incomplete employee profiles, conditional fields prevent blank data from showing up in signatures.
  • Optional social links Add LinkedIn or Twitter icons that only appear when the employee has filled in their profile URL.

Getting Started

If you're using one of Lastline's built-in templates, many common fields are already wrapped with conditional comments out of the box. For custom HTML templates, you can add conditional comments to any section by following the syntax above.

  1. Open your signature template in Lastline's signature editor.
  2. Identify fields that may be empty for some employees (phone, title, department, etc.).
  3. Wrap those sections with <!--[if FIELD]--> and <!--[/if FIELD]--> comments.
  4. Preview the signature with different employee profiles to verify.
  5. Deploy the template.