Logo Text Blaze
  • Products
    • Text Blaze
      Snippets and templates
    • AI Blaze
      AI writing and editing
    • Data Blaze
      Tables and sheets
    Downloads
    • Add to Chrome
    • Windows app
    • MacOS app
  • By function
    • Support & operations
    • Sales
    • Healthcare
    • Education
    • Recruiting
    • Marketing
    Business
    • For teams
  • Resources
    • Documentation
    • Community forum
    • Gallery
    • Contact us
  • Pricing

Documentation

No search results

Text Blaze

Loading...

Data Blaze

Loading...

Community Forums

Loading...
Add to Chrome –  It's Free! Go to Dashboard ›
Docs > Guides
  • Guides
    • Quick Start
    • Sharing Snippet Folders
    • Dynamic Commands
    • Date and Time
    • Autopilot
    • Forms
    • Formulas
    • Rules & Validation
    • Tables in Snippets
    • Connect Other Apps
    • Tidying Whitespace
    • Lists
    • Read Data from Websites
    • Teams and Organizations
  • Tutorial Videos
  • Gallery
  • Frequently Asked Questions
  • Formula Reference
  • Dynamic Commands
    • Using Dynamic Commands
    • {=} (Formula Command)
    • {button}
    • {click}
    • {clipboard}
    • {cursor}
    • {error}
    • {formdate}
    • {formmenu}
    • {formparagraph}
    • {formtext}
    • {formtoggle}
    • {if}
    • {import}
    • {key}
    • {link}
    • {note}
    • {repeat}
    • {run}
    • {site}
    • {snippet}
    • {time}
    • {user}
    • {wait}
  • Connected Snippets
    • Connected Snippets Overview
    • {image}
    • {urlload}
    • {urlsend}
    • {dbselect}
    • {dbinsert}
    • {dbupdate}
    • {dbdelete}
  • Command Packs
    • Capitalize
    • Gmail
    • LinkedIn
    • Randomize

What's on this Page

  • The trim setting
  • Trimming whitespace in formulas
  • Where to put your line breaks in Text Blaze
  • A note on the note command
Guides

Tidying Whitespace

Summary: 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 how to get rid of any spaces and why this happens.

Quick Overview Video

If you're using advanced commands inside of your snippets you may be formatting your snippet using line breaks or spaces to improve readability for your team or yourself.

Any whitespace that you're using to format the snippet itself will also appear in the snippet's final output.

The first section will show you a command setting to quickly remove whitespace.

Also, if you're curious about why this happens, we'll cover it in more detail in the Where to put your line breaks in Text Blaze section.

The trim setting

Every Text Blaze command has an optional trim setting that allows you to remove whitespace around the command.

The trim setting can take one of four values:

  1. "yes" - trim whitespace on all sides of the command.
  2. "no" - Do not trim any whitespace at all. ("no" is the default value if the trim setting is omitted from a command.)

Before getting to the final two values you can use, let's see a quick example:

The Trim Command
[ {time: LL} ]

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

Notice how if you add spaces to the top and bottom of the second {time} command the final output will still be clean and without whitespace.

But, what if you want to only remove whitespace on a single side of the command? The two final values that you're able to use for the trim setting are left and right. They remove whitespace only on a single side. See the example below.

Trimming One Side
[ {time: LL; trim=yes} {formtext: default=Hello} ]

[ {time: LL; trim=left} {formtext: default=Hello} ]
_

Notice how the top example will put the form right beside the time. That's because it's removing all the whitespace completely around the command with the yes value. The bottom example, on the other hand, allows the form to be directly below the time command. Using right or left as a value is useful when you want more fine-grained control.

Try it out

  • Experiment with the trim setting on the two {formtext} commands above. Observe what happens when you use yes, left, or right.

What if you're using the {=} (Formula Command) command and you need to get rid of additional whitespace for some input? Let's dive into how to do that in the next section.

Trimming whitespace in formulas

If you're using the {=} (Formula Command) command, the Text Blaze formula language has a trim function that will remove whitespace from strings in formulas.

For example:

Sample
{=trim(" abc ") & trim(" xyz ")}
_

Here's another, more advanced example. Let's say that you've just retrieved a user's full name from the website that you're on using the Text Blaze {site} command. But, due to the formatting on the website, it comes with a bunch of extra linebreaks and spaces.

Unlike the trim setting which removes all whitespace (including line breaks), Text Blaze's trim function only removes whitespace on the left and right sides. If you would like to remove linebreaks, you need to use the replace function. Here's an example below.

Trim and Replace Function
{name=" John Doe "} {=name}
{=replace(name, "\n", "")}
_

Double click the name variable above and notice how the formatting of the string contains spaces and linebreaks.

Try it out

  • Observe how using the replace function above causes the name to display as "JohnDoe". What change would you have to make to the function to make it display as "John Doe"?

Where to put your line breaks in Text Blaze

Generally, Text Blaze will output your snippet as is, including all the whitespace you've added. Let's dive a bit more technical example using multiline commands.

With multiline commands like {if} or {formtoggle} you generally want to have trailing or leading new lines be within the command. This can be counterintuitive as it's generally not how you would write the snippet by default.

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:

Let's look at one last example. With multiline commands like {if} or {formtoggle} you generally want to have trailing or leading new lines be within the command. This can be counterintuitive as it's generally not how you would write the snippet by default. Let's see an example of this below.

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}, {repeat}, and the {note} commands.

A note on the note command

Text Blaze provides you with the {note} command. By default, the contents of a note are shown in the snippet's preview but are not inserted as part of the snippet. Despite this, the note command still takes up the whitespace used in the final snippet output. Let's see an example:

Note command using whitespace
{note: trim=yes; preview=no} Make sure to do X, Y and Z before emailing this snippet out!{endnote} Dear Colleague...
_

Notice how there's a line break above "Dear Colleague...". It's advised that you use the trim setting on notes so that whitespace is not included in your final snippet output.

About

Plans and Pricing
Sharing Snippets
Text Blaze for Business
Forms
Autopilot
Dynamic Commands
Command Packs
Text Blaze for Windows
Text Blaze for macOS

Support

Get Started with Text Blaze
Contact Us
Documentation
Community Forum
Blog
Gallery
Engineering Blog

Solution for

Business
Customer Support
Recruiters
Education
Healthcare
Sales
Property Managers
AI

Other

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