bib2tpl Templates

bib2tpl uses the @ symbol as tag delimiter since it does not conflict with any major programming or design language as far as I know. Additional symbols have been chosen in the style of C syntax. The template tags are replaced with respect to the following rules. You can use all tags arbitrarily often. Some restrictions do apply, though, and are noted as appropriate.

Global Level

The value of these tags are the same everywhere.

@globalcount@ The total number of entries shown
@globalgroupcount@ The number of groups shown
@{group@ [...] @}group@ The enclosed part is evaluated for each group. Do not nest multiple instances.

Group Level

These tags are only valid inside @{group@ [...] @}group@ and are replaced with values depending on the individual entry groups. If your template does not have the enclosing group tags, grouping is automatically turned off by the converter.

@groupkey@ The group’s name as determined by the group parameter
@groupid@ A unique, standardised identifier; can be used as HTML id, for example
@groupcount@ Number of entries in this group
@{entry@ [...] @}entry@ The enclosed part is evaluated for each entry in this group. Do not nest multiple instances. Can appear outside of group tags if grouping is turned off.

Entry Level

These tags are only valid inside @{entry@ [...] @}entry@ and are replaced with values dependent on the individual entries.

@entrykey@ The entry’s key as given in the BibTeX source
@entrytype@ The entry’s type as given in the BibTeX source
@field@ The entry’s value for key field as given in the BibTeX source
@?field@ [...] @;field@ The enclosed part is evaluated if and only if key field is set for this entry
@?field@ [1] @:field@ [2] @;field@ Enclosed part [1] is evaluated if field is set, [2] otherwise. You can use more specific conditions; see below. Do not not nest multiple instances checking the same field.

Conditions

You can use a couple of comparators in conditions: , >=, ==, != and ~, for instance like that: @field==value@. They evaluate to true if and only if the specified field exists for the entry at hand, and if the following conditions are fulfilled:

  • For (>=), both value and entry field content have to be numeric strings and the number in the entry field has to be less or equal (greater or equal) than the given value.
  • For == (!=), value has to be the same (another) string as the one in the entry field.
  • For ~, the entry field's content has to match the regular expression given (without delimiters) in value.

Note that conditions are applied before sanitisation.

Examples

If you have created other nice templates, please let me know or send me a pull request.