Logo Text Blaze

  • Docs
  • Community
  • Documentation

    Loading...

    Community Forums

    Loading...
Add to Chrome –  It's Free! Go to Dashboard ›

What's on this Page

  • Where to put your line breaks
  • The trim setting
  • Trimming whitespace in formulas
GUIDES

Tidying Whitespace

When using advanced Text Blaze features like {formtoggle} or {if}, you may sometimes see extra line breaks or new lines in your inserted snippets. This guide walks you through why this happens and how to get rid of any extra spaces.

Quick Overview Video

Where to put your line breaks

Take this example of a snippet where we have three sections the user can optionally include when they use the snippet.

Sample
Intro text...

{formtoggle: name=Option 1}Optional section 1...{endformtoggle}

{formtoggle: name=Option 2}Optional section 2...{endformtoggle}

{formtoggle: name=Option 3}Optional section 3...{endformtoggle}

Concluding text...
_

This snippet will insert perfectly if you choose all three sections, but if you don't choose them all, you'll see extra whitespace when inserting. For example, if we only checked the third we would get:

Intro text...




Optional section 3...

Concluding text...

This is because when you uncheck a {formtoggle} command, Text Blaze removes everything inside the toggle, but since we have the line breaks outside the toggle they are kept.

Fortunately, the fix is very simple: just move the line breaks inside of the toggles. Then they will be removed when you uncheck the toggles. Doing this, you should end up with something like this:

Sample
Intro text...{formtoggle: name=Option 1}

Optional section 1...{endformtoggle}{formtoggle: name=Option 2}

Optional section 2...{endformtoggle}{formtoggle: name=Option 3}

Optional section 3...{endformtoggle}

Concluding text...
_

That's a little harder to read in the snippet source, but it will give you exactly what you want when you insert it no matter which sections you check.

This tip also applies to the {if} and {repeat} commands.

The trim setting

Every command has an optional trim setting that allows you to remove whitespace before or after the command.

The trim setting can take one of four values: "yes" to trim on both sides, "left" to trim on the left side only, "right" to trim on the right side only, and "no" to not trim at all (the default if the trim setting is omitted). Let's see it at work with the {time} command.

Sample
[ {time: LL} ]

[ {time: LL; trim=yes} ]

[ {time: LL; trim=left} ]

[ {time: LL; trim=right} ]
_

The trim setting can also be used to improve our example above by letting us add some additional whitespace to make the snippet source more readable without changing the final insertion:

Sample
Intro text...

{formtoggle: name=Option 1; trim=left}

Optional section 1...{endformtoggle}

{formtoggle: name=Option 2; trim=left}

Optional section 2...{endformtoggle}

{formtoggle: name=Option 3; trim=left}

Optional section 3...{endformtoggle}

Concluding text...
_

Trimming whitespace in formulas

Lastly, for our advanced formula users, the Text Blaze formula language has a trim function that will remove whitespace from strings in formulas.

For example:

Sample
{=trim(" abc ") & trim(" xyz ")}
_
  • Guides
    • Quick Start
    • Teams and Organizations
    • Forms
    • Sharing Snippet Folders
    • Autopilot
    • Tidying Whitespace
  • Tutorial Videos 🎬
  • Examples
    • Email
    • Invoice
    • Library Notice
  • Frequently Asked Questions
  • Formula Reference
  • Dynamic Command Reference
    • Using Dynamic Commands
    • formula ({=})
    • {click}
    • {clipboard}
    • {cursor}
    • {error}
    • {formdate}
    • {formmenu}
    • {formparagraph}
    • {formtext}
    • {formtoggle}
    • {if}
    • {import}
    • {key}
    • {link}
    • {note}
    • {repeat}
    • {site}
    • {snippet}
    • {time}
    • {user}
    • {wait}
  • Connected Snippets
    • Overview
    • {image}
    • {urlload}
    • {urlsend}

About

Plans
Text Blaze for Business
Sharing Snippets
Forms
Autopilot
Dynamic Replacements

Support

Contact Us
Documentation
Community Forum
Blog

Other

Privacy Policy
Terms of Service
Open Source Licenses
© 2020 Blaze Today Inc