This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

insertbefore Operator

 23rd February 2022 at 12:44am
purposeinsert an item T into a list immediately before an item B
inputa selection of titles
suffixIntroduced in v5.2.3 (optional) the name of a variable containing the title of the tiddler before which this one should be inserted
parameterIntroduced in v5.2.2 the insertbefore operator accepts 1 or 2 parameters, see below for details
outputthe input tiddler list with the new entry inserted

Learn more about how to use Filters

Introduced in v5.2.2

The insertbefore operator requires at least one parameter which specifies the title to insert into the input list. A second parameter can be used to specify the title before which the new title should be inserted.

Introduced in v5.2.3

Using the suffix to specify B, the title before which the new title should be inserted, is deprecated. Instead, the two-parameter form is recommended. If the two-parameter form is used, the suffixes start and end can be used to specify where the item should be inserted if B is not found.

insertbefore:<before-title-variable>[<title>]
insertbefore:<missing-location>[<title>],[<before-title>]
  • title : a title T to insert in the input list.
  • before-title : (optional). Insert T before this title B in the input list.
  • before-title-variable : (optional). The name of a variable specifying B instead of the before-title parameter.
  • missing-location : (optional). Either start or end: where to insert T if B is not found in the list.

If the item B isn't present in the input list then the new item is inserted at the end of the list. Introduced in v5.2.3 The suffixes start and end can be spedified to control where the new item is inserted when B is not found. The suffix end is the default, inserting the new item at the end of the list. The suffix start will cause the new item to be inserted at the start of the list when B is not found.

Tip
Either parameter can be a string, a text reference or a variable

Tip
If B is specified as both a suffix and a parameter, the parameter takes precedence

Examples