Introducing the Tweet Element Template

Version 1.6.0 of this plugin introduced a new capability. Tweet structure customization.

You can now rearrange the order that tweet elements are placed in, and provide custom separators between those elements.

Use the new setting on Tweet This’ settings page, entitled Tweet Element Template, to make the changes.

 

Templating Basics

Template Tags

The new templating capability functions by substituting template tags with the actual content.  An example template tag is this:

This value will be replaced by the URL to your post, if one is specified or automatically generated.

To tell Tweet This that it should search for, and replace template tags, you enclose it in {{}}. For example:

 

Template Element Separators

If you want to add a separator on either side of the template tag, you have two options. The first are separators that will always be present, even if there is no content for that template tag. The second are conditional separators that are only there if the template tag has content.

To do the first, you place the separator outside the curly brackets. For example, if I wanted to put a hyphen on either side of the post URL, even if the tweet does not have a post URL in it, I would do this:

 

To do the second, the separator goes inside the curly brackets (but not the template tag). For example, if I wanted the same hyphens, but only when their is a post URL in the tweet, I would do this:

 

Spaces would look like this:

Always present

– or –

Conditionally present

 

Template Structure

First, let’s look at all the possible template tags.

  • {text}: The text to tweet.
  • {post_url}: The URL to the post the Tweet This box is placed within, or its overridden value.
  • {hidden_hashtags}: Any hidden hashtags for the tweet.
  • {hidden_urls}: Any hidden URLs for the tweet.
  • {twitter_handles}: The twitter handles to append to the tweet.

 

You will take these template tags, and their separators, and combine them to form the resultant tweet element template. For example, the default element template is as follows:

 

 

Examples

Default

Template:

 

Sample Results:

With all elements

With no hidden hashtags specified

With everything disabled, leaving only the text

 

Simple Rearrangement

Template:

*Notice that the only change is {{ {post_url}}}  is moved before the hidden content

 

Sample Results:

With all elements

With no hidden hashtags specified

With everything disabled, leaving only the text

 

 

Mixed Separator Types

Template:

 

Sample Results:

With all elements

With no hidden hashtags specified

With everything disabled, leaving only the text

 

Notice the separator behavior. Permanent separators (outside the curly brackets) remain, even if the content is missing. Conditional separators disappear.

 

Behavior Notes

  • Newlines are not currently supported in the template. They will display as a single space. Newline support will likely be added in a future update.
  • You can repeat template tags if desired.
  • All occurrences of “{{” and “}}” will be removed from the resulting tweet. These are special symbols to Tweet This’ templating engine.
  • Invalid template tags will not be removed/replaced. {{{some_invalid_tag}}}  will show in the resultant tweet as {some_invalid_tag}
  • Omitting template tags means that content will not be placed in any tweet, even if that content is defined.
  • Leave the Tweet This’ Tweet Element Template setting blank to automatically use the default.

Leave a Reply

Your email address will not be published. Required fields are marked *


*