Skip to content

Formatting And Data

Content below is copied from the official Neto/Maropost docs so you can edit and annotate it locally.


format

format

Formats the content within the tag based on the tag parameters

Example

[%format type:'currency'%][@price@][%/format%]

Usage

Format tags are used to manipulate the output of data created by Neto Template Tags. Here are some examples:

csv - Preparing text to be exported in a CSV file

Escapes the " character in a string so it can be used in a CSV export. Replaces " with "":

[%format type:'csv'%]Shinkansen is called a "bullet train"[%/format%] Displays Shinkansen is called a ""bullet train"".

currency - display provided value as a price

Adds currency symbol, decimal point, and two decimal places to a number:

[%format type:'currency'%]19[%/format%] Displays $19.00.

date - Generate a datetime or format an existing one

The date value can either be an exact or partial datetime, e.g: [@arrival_date@], [@date_placed@], 2023-01-01 14:00:00, 01/01/2023. Or it can be a relative string, e.g: 10 days time, 1 year ago, now. Available relative terms: {number} [year|yr|month|mon|week|wk|day|hour|hr|minute|min][s] [ago|time] [eom|som] [now|today] where:

  • ‘ago’: Specifies a datetime in the past

  • ’time’: Specifies a datetime in the future

  • ’eom’: End Of Month

  • ’som’: Start Of Month

  • ’now’: Current datetime, down to the second

  • ’today’: Current datetime, down to the day

[%format type:'date' format:'#D #K #Y at #H:#I:#S'%]now[%/format%] Displays 15 August 2023 at 13:06:08.

number - manipulate provided value to add or remove decimal places, round the value, or append/prepend text

Add a comma separator for larger numbers and include decimal places:

[%format type:'number' sp:',' dp:'2'%]1900[%/format%] Displays 1,900.00.

percent - convert provided value into a percentage

Rounds the number and adds a percentage sign:

[%format type:'percent'%]95.7[%/format%] Displays 96%.

text - manipulate provided text value to change case, length, trim or remove, etc

Change to lower case and display the first 16 characters:

[%format type:'text' case:'lower' maxlength:'16'%]One so immersive the device[%/format%] Displays one so immersive.

Parameters

NameOptionsDescription
type:''csv, currency, date, number, percent, textThe type of format you wish to apply, each type has its own set of parameters that are specific to the type. Options:
dpno_zero:''0/1Works with type currency, a boolean that when true will remove the decimal place if the cents value is 0 or 00
add:''StringWorks with type date, set a time value you would like to add or remove from a provided datetime, example: -1 hour, 1 day, 5 min, 2 month
unix_timestamp:''epoch numberWorks with type date, use instead of providing a date value. Formats a provided unix timestamp, e.g: 1700809303 to 24/11/2023
default:''StringWorks with type date, fallback if the date value specified isn’t a valid datetime - can be plain text or a B@SE tag
format:''Code (see chart)Works with type date and determines the output of the date format

Date format codes

CodeDescription
Year
#YNumeric representation (4 digits)
#yShort numeric representation (2 digits)
Month
#MNumeric representation (04)
#mNumeric representation without leading zero (4)
#KTextual representation (April)
#kShort textual representation (Apr)
Date
#DNumeric representation (07)
#dNumeric representation without leading zeros (7)
Day
#WTextual representation (Friday)
#wShort textual representation (Fri)
#NNumeric day of week from 1 (Monday) to 7 (Sunday) (6)
#nNumeric day of week from 0 (Sunday) to 6 (Saturday) (6)
Hours
#H24-hour numeric representation (04:30)
#h24-hour numeric representation without leading zeros (4:30)
#G12-hour numeric representation (09:45)
#g12-hour numeric representation without leading zeros (9:45)
Minutes
#INumeric representation (06)
#iNumeric representation without leading zero (6)
Seconds
#SNumeric representation (09)
#sNumeric representation without leading zero (9)
AM/PM
#AUppercase ante meridiem and post meridiem (AM or PM)
#aLowercase ante meridiem and post meridiem (am or pm)
Unix
#UUnix epoch time (seconds since 1970-01-01 00:00:00 GMT) given a local time
#uUnix epoch time (seconds since 1970-01-01 00:00:00 GMT) given a GMT time
Timezones
#ZNumeric representation of the timezone offset (+1000)

More parameters

NameOptionsDescription
dp:''IntegerWorks with type number, it will format the number to the specified number of decimal places
pf:''StringWorks with type number and currency, this string will be prepended to the output. Eg. ”$” or “AUD $“
sp:''StringWorks with type number, adds the string specified at every thousand interval. Typically you would place a , here, so 10000 would be formatted as 10,000
tl:''StringWorks with type number, adds the string specified to the end of the number formatted
tl_plural:''StringWorks with type number, generates a text block based on the value, so if the item is plural ie. There is two, we might print the text “items have”
tl_unit:''StringWorks with type number, generates a text block based on the value, so if the item is singular ie. There is one, we might print the text “item has”
round:''up/downWorks with type number, rounds the value up or down to the nearest whole number
addbr:''1/0Works with type text. Converts newline characters to <br> tags
case:''upper, lowerWorks with type text, forces the content to either be upper or lower case
maxlength:''IntegerWorks with type text, limits the maximum amount of characters contained within the tag
noeol:''1/0Works with type text. Removes carriage returns from the text
nohtml:''1/0Works with type text, when true it will escape HTML
rmhtml:''1/0Works with type text, when true it will strip HTML
trim:''e, l, r, aWorks with type text, trims out spaces depending on the value used. l & r trim out spaces to the left and right respectively, a trims out all space between text and e trims out all space between text down to the integer attached to it, so for example, trim:‘e1’ will trim down to 1 space, removing the potential for double spaces
truemaxlength:''IntegerWorks with type text, limits the maximum amount of characters contained within the tag after nohtml/rmhtml has been applied
wordlength:''IntegerWorks with type text, limits the maximum number of characters before the word is hyphenated and the remainder of the word appears on a new line

Your annotations

Use this section to note anything that’s incorrect in the official docs or extended by your implementation.