Text Expander

Text Expander is a browser based, text expander and template tool with markdown, conditionals, and loops. It's perfect for creating form emails, "mail merging" data into text, and pro formas. A key design feature is that it's very difficult to make mistakes like forgetting to set values.

There's nothing to install, it's running right here in your browser. Edit / paste a template below, render it, and copy the output to wherever you like.

For a full reference you should take a look at the language reference.

Language Reference & More ...

Front Matter

---
# a comment, tell your minions which values to edit.
simple: value
list: [
  value1
  value2
]
keyList: {
  key1: value1
  key2: value2
}
---

This is where you define any variables or values you're going to use in your template. It should be the first thing in your template, with three dashes --- before and after.

It's written in HJSON which is pretty much just JSON without without all the quotes and commas. See the HJSON project for the full language reference. Notably, HJSON can parse JSON, so if you're generating templates from a script or something you could just JSON.stringify your front matter.

If JSON doesn't mean much to you, do not fear, there's really not much you need to know.

Templates check the variables you define to figure out what how to manipulate your template.

If you set a variable with the name simple to be value, then if you render a template like simple is ${simple} the output will be simple is value. The more complex structures like if, and for loops below work on the same concept.

Markdown

## Heading
Some *bold* text

 * list 1
 * list 2

A [link](http://foo.com) to some webpage

After conditionals, loops, and interpolation are resolved, the output will be rendered as markdown.

In some cases it might be easier to copy the "raw" markdown from text expander and render the markdown somewhere else, so you can switch off the markdown rendering.

Take a look at Markdown-Here's Cheat Sheet for a full language reference.

Interpolation

---
name: James
---
Hi there ${name}

Interpolation allows variables to be substituted with their values from front matter.

If you're creating a template for yourself or others to re-use, set values to null so an error will be shown if someone forgets to set them before rendering.

---
name: null
---
Hi there ${name}

Conditionals

---
weekday: tuesday
---
::if (weekday == 'monday') {
  show this if weekday is monday
::} else if (weekday == 'tuesday') {
  show this if weekday is tuesday
::} else {
  show this if weekday is any other value
::}

These are if / then / else statements. Anything in the brackets is evaluated by jexl, so it's not really javascript but similar, and you can use some fairly complex queries.

See the jexl package for a full reference.

Loops

---
list: [
  one
  two
  three
]
payments: {
  Jane: $100
  Jeff: $110
  John: $120
}

---
::for (item in list) {
  item number ${item}
::}
::for (amount, name in payments) {
  pay ${name} ${amount}
::}

in the content block of a for loop, the item variable in ::for (item in list) { is available to interpolate.

This works with objects too, if you're into that.

Formatting Trouble

For most things in the browser, you'll get pretty formatting if you just copy and paste the output.

If you're having trouble, the first thing to try might be to switch off the Render Markdown option, then copypasta the raw output, and use the markdown-here browser extension to render it in place.

If you're still not having any joy, I'd love to hear from you. Use the contact form or reach out to me on twitter.

Privacy

Templates are rendered in your browser. Your templates are never transmitted to our server.

Like most websites we do collect usage data, like page loads and renders, and use cookies to your basic preferences.