Template Mocks - Version 2.0 (current)¶
Introduction¶
Template Mock evaluates Handlebars expressions provided by the customer.
Handlebars is a simple templating language that uses template string and the input model to generate output.
Handlebars templates look like a regular text with embedded Handlebars expressions ({{
, some contents, followed by a }}
).
Here are some helpful topics in Handlebars official documentation you may find useful while implementing your mocks:
- Basic usage
- Path expressions
- Special characters escaping
- Subexpressions
- Whitespace control
- Template comments
Input Model¶
The input model available for Template Mock consists of two objects: req
and state
. The req
(Request Model) object
represents the request sent towards the domain identifying particular SmartMock.io workspace. The state
(State)
object represents the container for the stateful data for the workspace (see Stateful Responses
section for more details.)
Example - accessing the request model
Request HTTP method:
GET
Template:
{{req.method}}
Rendered response body:
GET
Example - accessing the state
The state contains an array of users:
{"users": [{"id": 1, "name": "John"}, {"id": 2, "name": "Gregory"}] }
Template:
{{ state.users.[0].name }}
Rendered response body:
John
Request Model¶
The HTTP request from client is parsed, supplied to the template mock and available as req
variable.
The following request attributes are available:
Method¶
req.method
- Value of request HTTP method.
URL¶
req.url
- The URL, the client, used to make the request. The returned URL contains a protocol, server name, port number,
and the server path, but it does not include query string parameters.
Example
Request URL:
http://somedomain.app.smartmock.io/user/John%20Doe/permissions?param1=value1
Template:
{{req.url}}
Rendered response body:
http://somedomain.app.smartmock.io/user/John%20Doe/permissions
Path¶
req.path
- The path part of the request's URL. It does not decode the path.
Example
Request URL:
http://somedomain.app.smartmock.io/user/John%20Doe/permissions?param1=value1
Template:
{{req.path}}
Rendered response body:
/user/John%20Doe/permissions
Path Parameters¶
req.pathParams.[name]
- Value of path parameter (see Path Parameter Matchers) extracted from request path.
If the parameter not found, the empty string is used.
Example
Path matcher:
/user/{userId}/permissions
Request URL:
http://somedomain.app.smartmock.io/user/123abc/permissions?param1=value1
Template:
{{req.pathParams.[userId]}}
Rendered response body:
123abc
Path Segments¶
req.pathSegments.[n]
- Value of nth URL path segment. Zero indexed. If segment not found, the empty string is used.
Example
Request URL:
http://somedomain.app.smartmock.io/user/123abc/permissions?param1=value1
Template:
{{req.pathSegments.[1]}}
Rendered response body:
123abc
Host¶
req.host
- Name of the host the request is made to.
Example
Request URL:
http://somedomain.app.smartmock.io/user/123abc/permissions?param1=value1
Template:
{{req.host}}
Rendered response body:
somedomain.app.smartmock.io
Headers¶
req.headers.[name]
- Values of the request headers with the given name. If value not found, the empty string is used.
req.headers.[name].[n]
- Value of nth request header with the given name. Zero indexed. If value not found, the empty string is used.
Example
Request Headers:
Content-Type: application/json
AuthToken: abc123
AuthToken: bcd123
Template:
{{req.headers.[AuthToken]}} - {{req.headers.[AuthToken].[1]}}
Rendered response body:
abc123 bcd123
Cookies¶
req.cookies.[name]
- Values of the request cookies with the given name. If value not found, the empty string is used.
req.cookies.[name].[n]
- Value of nth request cookie with the given name. Zero indexed. If value not found, the empty string is used.
Example
Request Headers:
Cookie: PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;
Template:
{{req.cookies.[PHPSESSID]}}
Rendered response body:
298zf09hf012fh2
Query Parameters¶
req.query.[name]
- Values of the request query parameters with the given name. If value not found, the empty string is used.
req.query.[name].[n]
- Value of nth request query parameter with the given name. Zero indexed. If value not found, the empty string is used.
Example
Request URL:
http://somedomain.app.smartmock.io/user/123abc/permissions?page=1&size=10
Template:
{{req.query.[page]}}
Rendered response body:
1
Query String¶
req.queryString
- Value of request URL query string. If the request URL has no query string, the empty string will is used.
Example
Request URL:
http://somedomain.app.smartmock.io/user/123abc/permissions?page=1&size=10
Template:
{{req.queryString}}
Rendered response body:
page=1&size=10
Body¶
req.body
- Value of request body. The return value is of string type. You may use appropriate helpers to parse it
and extract business fields values from it.
Example
Request body:
{"id" : 123, "name": "John", "surname" : "Doe"}
Template:
{{req.body}}
Rendered response body:
{"id" : 123, "name": "John", "surname" : "Doe"}
JSON Body¶
req.jsonBody
- Parsed request JSON body. This property is returned only when the request body is a valid and parsable JSON string.
Otherwise, appropriate message gets logged into workspace's Request Log and the empty string is returned.
Example
Request body:
{"id" : 123, "name": "John", "surname" : "Doe"}
Template:
{{req.jsonBody.name}} {{req.jsonBody.surname}}
Rendered response body:
John Doe
Accessing State¶
{{state.[Key].[Subkey].[index]}}
- Retrieve a value from current state of workspace. State may be initialized in Dynamic Mocks.
Please note that access to nested object is done through the '.[Key]' operator. If a value does not exist under a given key, an empty string is returned.
See more about state.
Example
State:
{"people": [{"name" : "John", "surname": "Doe"},{"name" : "Eric", surname: "Jackson"}]}
Template:
{{state.[people].[0].[name]}} {{state.[people].[0].[surname]}}
Rendered response body:
John Doe
Helpers¶
Besides accessing request fields, it's possible to include some logic in the form of built-in helpers. Helper names are case sensitive.
Random UUID Helper¶
randomUuid
- Generates UUID type 4 value.
Example
Template:
{{randomUuid}}
Rendered response body:
400bc69f-9b06-43c2-8497-ba8755fe7ef6
Date/Time Helper¶
now pattern='<pattern>' offset='<offset>' timezone='<zone>'
- Generates string value of current time in given zone, with given format, adding given offset.
Example 1
Template:
{{now pattern='YYYY-MM-DD[ at ]HH:mm:ss' offset='-1 hours' timezone='UTC'}}
Rendered response body:
2020-05-10 at 11:12:13
Example 2
Template:
{{now}}
Rendered response body:
2020-05-10T11:12:13Z
Parameters¶
Parameter | Description | Default value |
---|---|---|
pattern | Patterns based on a simple sequence of letters and symbols. Use "\" to escape single quote characters in format string. See details below. | ISO-8601 extended offset date-time format (YYYY-MM-DDTHH:mm:ss[Z] ) |
offset | Add or remove seconds/minutes/hours/days/months/years. Format: +/-<number> <unit> examples: +1 years , -2 months See Moment.js "Add" documentation for a list of time units. |
-0 seconds |
timezone | Time zone date(time) will be placed in. Sample values: UTC , CET , America/Los_Angeles , Etc/GMT+1 . See column "TZ Database name" on Wikipedia article for a list of available time zones |
UTC |
Pattern details¶
Token | ||
---|---|---|
Month | M | 1 2 ... 11 |
Mo | 1st 2nd ... 11th | |
MM | 01 02 ... 11 | |
MMM | Jan Feb ... Nov | |
MMMM | January February ... November | |
Quarter | Q | 1 2 3 |
Qo | 1st 2nd 3rd | |
Day of Month | D | 1 2 ... 30 |
Do | 1st 2nd ... 30th | |
DD | 01 02 ... 30 | |
Day of Year | DDD | 1 2 ... 364 |
DDDo | 1st 2nd ... 364th | |
DDDD | 001 002 ... 364 | |
Day of Week | d | 0 1 ... 5 |
do | 0th 1st ... 5th | |
dd | Su Mo ... Fr | |
ddd | Sun Mon ... Fri | |
dddd | Sunday Monday ... Friday | |
Day of Week (Locale) | e | 0 1 ... 5 |
Day of Week (ISO) | E | 1 2 ... 6 |
Week of Year | w | 1 2 ... 52 |
wo | 1st 2nd ... 52nd | |
ww | 01 02 ... 52 | |
Week of Year (ISO) | W | 1 2 ... 52 |
Wo | 1st 2nd ... 52nd | |
WW | 01 02 ... 52 | |
Year | YY | 70 71 ... 29 |
YYYY | 1970 1971 ... 2029 | |
YYYYYY | -001970 -001971 ... +001907 +001971 Note: Expanded Years (Covering the full time value range of approximately 273,790 years forward or backward from 01 January, 1970) | |
Y | 1970 1971 ... 9999 +10000 +10001 Note: This complies with the ISO 8601 standard for dates past the year 9999 | |
Era Year | y | 1 2 ... 2020 |
Era | N | BC AD Note: Abbr era name |
NN | BC AD Note: Narrow era name | |
NNN | Before Christ, Anno Domini Note: Full era name | |
Week Year | gg | 70 71 ... 29 |
gggg | 1970 1971 ... 2029 | |
Week Year (ISO) | GG | 70 71 ... 29 |
GGGG | 1970 1971 ... 2029 | |
AM/PM | A | AM |
a | am | |
Hour | H | 0 1 ... 22 |
HH | 00 01 ... 22 | |
h | 1 2 ... 11 | |
hh | 01 02 ... 11 | |
k | 1 2 ... 23 | |
kk | 01 02 ... 23 | |
Minute | m | 0 1 ... 58 |
mm | 00 01 ... 58 | |
Second | s | 0 1 ... 58 |
ss | 00 01 ... 58 | |
Fractional Second | S | 0 1 ... 8 |
SS | 00 01 ... 98 | |
SSS | 000 001 ... 998 | |
SSSS ... SSSSSSSSS | 000[0..] 001[0..] ... 998[0..] 999[0 | |
Time Zone | z or zz | EST CST ... MST PST Note: as of 1.6.0, the z/zz format tokens have been deprecated from plain moment objects. Read more about it here. However, they *do* work if you are using a specific time zone with the moment-timezone addon. |
Z | -07:00 -06:00 ... +06:00 +07: | |
ZZ | -0700 -0600 ... +0600 + | |
Unix Timestamp | X | 1360013296 |
Unix Millisecond Timestamp | x | 1360013296123 |
Escaping characters¶
To escape characters in format strings, you can wrap the characters in square brackets.
Example 3
Template:
{{now pattern='[today] dddd'}}
Rendered response body:
today Sunday
Unix Timestamp Helper¶
unixTimestamp unit='<unit>'
- Generates string representing number of milliseconds, seconds, minutes, hours, days since Jan 01 1970. (UTC)
Parameter | Description | Default value |
---|---|---|
unit | Time unit of timestamp. Possible values: MILLISECONDS , SECONDS , MINUTES , HOURS , DAYS |
SECONDS |
Random String Helper¶
randomString length=<length> type='<type>' case='<case>'
- Generates random string of given type with given length and given case.
Parameter | Description | Default value |
---|---|---|
length | Length of string | 10 |
type | Type of string. Possible types: ALPHABETIC , ALPHANUMERIC , NUMERIC , ALPHANUMERIC_AND_SYMBOLS |
ALPHABETIC |
case | Defines if letters are upper case or lower case. Possible values: UPPER , LOWER , none |
none |
Example 1 (alphabetic string)
Template:
{{randomString}}
Rendered response body:
EhFGqGiZpK
Example 2 (numeric string)
Template:
{{randomString length=5 type='NUMERIC'}}
Rendered response body:
22187
Example 3 (alphanumeric upper case string)
Template:
{{randomString length=20 type='ALPHANUMERIC' case='UPPER'}}
Rendered response body:
2TFO8F6YM0XBHFVGDZER
Random Number Helper¶
randomNumber min=<min> max=<max> fractionDigits=<digits>
- Generates random number greater or equal to min
and lower than max
with given number of fraction digits
Parameter | Description | Default value |
---|---|---|
min | inclusive minimum | 0 |
max | exclusive maximum | 100 |
fractionDigits | Number of fraction digits - useful for generating float values | 0 |
Example 1
Template:
{{randomNumber}}
Rendered response body:
82
Example 2
Template:
{{randomNumber min=1000 max=100000 fractionDigits=5}}
Rendered response body:
67342.60221
Assignment Helper¶
{{assign 'varName' varValue }}
- Creates auxiliary variable (varName
) in current context and assigns the value of varValue
to that variable.
It's not possible to assign value to the req
and state
objects.
This helper may be used to simplify templates that require complex helpers' compositions.
Example
Request body:
{"name" : "John", "surname": "Doe"}
Template:
{{assign 'name' req.jsonBody.name}}
{{name}}
Rendered response body:
John
Faker Helper¶
{{faker <fakeName> <...fakeArguments> lang='<lang>''}}
- Allows using the Faker library as a helper.
Parameter | Description | Default value |
---|---|---|
fakerName | String representing the specific fake type to be generated (address.zipCode , finance.account etc.) - see the list available at Faker's official documentation |
--- |
fakeArguments | Fake arguments. Values are dependent on the specific fake. Please check fakes documentation in the source code to check available arguments for specific helpers. | --- |
lang | Language locale. Supported values: az , cz , de , de_AT , de_CH , en , en_AU , en_AU_ocker , en_BORK , en_CA , en_GB , en_IE , en_IND , en_US , en_ZA , es , es_MX , fa , fr , fr_CA , fr_CH , ge , id_ID , it , ja , ko , nb_NO , nep , nl , nl_BE , pl , pt_BR , pt_PT , ru , sk , sv , tr , uk , vi , zh_CN , zh_TW |
en |
Available Fakes¶
Name | |
---|---|
Example | Sample output |
Description | Arguments |
address.zipCode | |
`{{faker 'address.zipCode'}}` | `67158-5600` |
Generates zip code. |
|
address.zipCodeByState | |
`{{faker 'address.zipCodeByState' 'TX' lang='en_US'}}` | `73301` |
Generates random zipcode from state abbreviation. If state abbreviation is not specified, a random zip code is generated according to the locale's zip format. |
|
address.city | |
`{{faker 'address.city'}}` | `Connland` |
Generates a random localized city name. |
|
address.streetName | |
`{{faker 'address.streetName'}}` | `Stark Island` |
Generates a random localized street name. | ----- |
address.streetAddress | |
`{{faker 'address.streetAddress'}}` | `806 Feil Loaf` |
Generates a random localized street address. |
|
address.secondaryAddress | |
`{{faker 'address.secondaryAddress'}}` | `Apt. 661` |
Generates a random secondary address. | ----- |
address.county | |
`{{faker 'address.county'}}` | `Buckinghamshire` |
Generates a random county name. | ----- |
address.country | |
`{{faker 'address.country'}}` | `Germany` |
Generates a random country name. | ----- |
address.countryCode | |
`{{faker 'address.countryCode'}}` | `LR` |
Generates a random country code. |
|
address.state | |
`{{faker 'address.state'}}` | `New Hampshire` |
Generates a random state name. | ----- |
address.stateAbbr | |
`{{faker 'address.stateAbbr'}}` | `NC` |
Generates a random state abbreviation. | ----- |
address.latitude | |
`{{faker 'address.latitude'}}` | `70.7711` |
Generates a random latitude. |
|
address.longitude | |
`{{faker 'address.longitude'}}` | `159.3064` |
Generates a random longitude. |
|
address.direction | |
`{{faker 'address.direction'}}` | `Northwest` |
Generates a random geographical direction. |
|
address.cardinalDirection | |
`{{faker 'address.cardinalDirection'}}` | `West` |
Generates a random geographical cardinal direction. |
|
address.nearbyGPSCoordinate | |
`{{assign 'loc' (JSONparse '[70.0, 60.0]')}} {{faker 'address.nearbyGPSCoordinate' loc 1 false}}` | `70.0056,60.0002` |
Generates a random GPS coordinates nearby the given coordinates. |
|
commerce.color | |
`{{faker 'commerce.color'}}` | `pink` |
Generates a random color. | ----- |
commerce.department | |
`{{faker 'commerce.department'}}` | `Outdoors` |
Generates a random department. | ----- |
commerce.productName | |
`{{faker 'commerce.productName'}}` | `Unbranded Fresh Shirt` |
Generates a random product name. | ----- |
commerce.price | |
`{{faker 'commerce.price' 10 20 2 '$'}}` | `$16.00` |
Generates a random price. |
|
commerce.productAdjective | |
`{{faker 'commerce.productAdjective'}}` | `Tasty` |
Generates a random product adjective. | ----- |
commerce.productMaterial | |
`{{faker 'commerce.productMaterial'}}` | `Concrete` |
Generates a random product material. | ----- |
commerce.product | |
`{{faker 'commerce.product'}}` | `Bacon` |
Generates a random product . | ----- |
commerce.productDescription | |
`{{faker 'commerce.productDescription'}}` | `The Football Is Good For Training And Recreational Purposes` |
Generates a random product description. | ----- |
company.companySuffix | |
`{{faker 'company.companySuffix'}}` | `Group` |
Generates a random company suffix. | ----- |
company.companyName | |
`{{faker 'company.companyName' }}` | `Hamill and Sons` |
Generates a random company name. |
|
company.catchPhrase | |
`{{faker 'company.catchPhrase' }}` | `Profit-focused explicit internet solution` |
Generates a random company catch phrase. | ----- |
company.bs | |
`{{faker 'company.bs' }}` | `evolve next-generation systems` |
Generates a random buzz sentence. | ----- |
company.catchPhraseAdjective | |
`{{faker 'company.catchPhraseAdjective' }}` | `Advanced` |
Generates a random catch phrase adjective. | ----- |
company.catchPhraseDescriptor | |
`{{faker 'company.catchPhraseDescriptor' }}` | `intermediate` |
Generates a random catch phrase descriptor. | ----- |
company.catchPhraseNoun | |
`{{faker 'company.catchPhraseNoun' }}` | `success` |
Generates a random catch phrase noun. | ----- |
company.bsAdjective | |
`{{faker 'company.bsAdjective' }}` | `cross-platform` |
Generates a random buzz sentence adjective. | ----- |
company.bsBuzz | |
`{{faker 'company.bsBuzz' }}` | `exploit` |
Generates a random buzz word. | ----- |
company.bsNoun | |
`{{faker 'company.bsNoun' }}` | `metrics` |
Generates a random buzz word noun. | ----- |
database.column | |
`{{faker 'database.column' }}` | `token` |
Generates a random database column. | ----- |
database.type | |
`{{faker 'database.type' }}` | `enum` |
Generates a random database type. | ----- |
database.collation | |
`{{faker 'database.collation' }}` | `utf8_general_ci` |
Generates a random database collation. | ----- |
database.engine | |
`{{faker 'database.engine' }}` | `MEMORY` |
Generates a random database engine. | ----- |
date.past | |
`{{faker 'date.past 10 '2010-01-01' }}` | `Wed Feb 21 2007 06:13:54 GMT+0100 (CET)` |
Generates a random date from the past. |
|
date.future | |
`{{faker 'date.future' 10 '2020-01-01' }}` | `Tue May 19 2020 14:26:53 GMT+0200 (CEST)` |
Generates a random date from the future. |
|
date.between | |
`{{faker 'date.between' '2010-01-01' '2020-01-01' }}` | ` Sat May 22 2010 17:06:10 GMT+0200 (CEST)` |
Generates a random date between two dates. |
|
date.recent | |
`{{faker 'date.recent' 10 '2020-01-01' }}` | `Thu Dec 26 2019 18:36:59 GMT+0100 (CET)` |
Generates a random recent date. |
|
date.soon | |
`{{faker 'date.soon' '2020-01-01' }}` | ` Mon Jan 06 2020 20:48:25 GMT+0100 (CET)` |
Generates a random soon date. |
|
date.month | |
`{{faker 'date.month' abbr=true}}` | `Jan` |
Generates a random month name. |
|
date.weekday | |
`{{faker 'date.weekday' abbr=true }}` | `Tue` |
Generates a random weekday name. |
|
finance.account | |
`{{faker 'finance.account' 10 }}` | `8509109839` |
Generates a random account number. |
|
finance.accountName | |
`{{faker 'finance.accountName' }}` | `Credit Card Account` |
Generates a random account name. | ----- |
finance.routingNumber | |
`{{faker 'finance.routingNumber' }}` | `296112809` |
Generates a random routing number. | ----- |
finance.mask | |
`{{faker 'finance.mask' 4 false true }}` | `...9846` |
Generates a random numeric mask. |
|
finance.amount | |
`{{faker 'finance.amount' 1 20 2 }}` | `5.74` |
Generates a random amount. |
|
finance.transactionType | |
`{{faker 'finance.transactionType' }}` | `payment` |
Generates a random transaction type. | ----- |
finance.currencyCode | |
`{{faker 'finance.currencyCode' }}` | `VUV` |
Generates a random currency code. | ----- |
finance.currencyName | |
`{{faker 'finance.currencyName' }}` | `Cape Verde Escudo` |
Generates a random currency name. | ----- |
finance.currencySymbol | |
`{{faker 'finance.currencySymbol' }}` | `BZ$` |
Generates a random currency symbol. | ----- |
finance.bitcoinAddress | |
`{{faker 'finance.bitcoinAddress' }}` | `3qf5fGisbKhiSQLoDQwe7dvWqu` |
Generates a random Bitcoin address. | ----- |
finance.litecoinAddress | |
`{{faker 'finance.litecoinAddress' }}` | `M3yTEUJxE1bR9PoeAQT2temGST4SrB` |
Generates a random Litecoin address. | ----- |
finance.creditCardNumber | |
`{{faker 'finance.creditCardNumber' 'Mastercard' }}` | `5207-2222-3328-0433` |
Generates a random credit card number. |
|
finance.creditCardCVV | |
`{{faker 'finance.creditCardCVV' }}` | `151` |
Generates a random credit card cvv. | ----- |
finance.ethereumAddress | |
`{{faker 'finance.ethereumAddress' }}` | `0x6ebeee71626fd3edb428dfd382c1dcb8e2a1f1f1` |
Generates a random Ethereum address. | ----- |
finance.iban | |
`{{faker 'finance.iban' true }}` | `AD40 0400 8199 R374 5H90 4J41` |
Generates a random IBAN number. |
|
finance.bic | |
`{{faker 'finance.bic' }}` | `HLBIINR1` |
Generates a random bank identification code (bic). | ----- |
git.branch | |
`{{faker 'git.branch' }}` | ` bandwidth-back-up` |
Generates a random git branch name. | ----- |
git.commitEntry | |
`{{faker 'git.commitEntry' }}` | ` quantify multi-byte protocol` |
Generates a random git commit entry. |
|
git.commitMessage | |
`{{faker 'git.commitMessage' }}` | `calculate neural transmitter` |
Generates a random git commit message. | ----- |
git.commitSha | |
`{{faker 'git.commitSha' }}` | `eea49609a96318acee11880f0d86ad3810985a1a` |
Generates a random git commit SHA. | ----- |
git.shortSha | |
`{{faker 'git.shortSha' }}` | `eb0d56d` |
Generates a random git commit short SHA. | ----- |
hacker.abbreviation | |
`{{faker 'hacker.abbreviation' }}` | `THX` |
Generates a random hacker abbreviation. | ----- |
hacker.adjective | |
`{{faker 'hacker.adjective' }}` | `redundant` |
Generates a random hacker adjective. | ----- |
hacker.noun | |
`{{faker 'hacker.noun' }}` | `interface` |
Generates a random hacker noun. | ----- |
hacker.verb | |
`{{faker 'hacker.verb' }}` | `connect` |
Generates a random hacker verb. | ----- |
hacker.ingverb | |
`{{faker 'hacker.ingverb' }}` | `hacking` |
Generates a random hacker gerund verb. | ----- |
hacker.phrase | |
`{{faker 'hacker.phrase' }}` | `Use the auxiliary XML hard drive, then you can connect the 1080p matrix!` |
Generates a random hacker phrase. | ----- |
image.image | |
`{{faker 'image.image' 640 480 true }}` | `http://placeimg.com/640/480/people?20729` |
Generates a random image link. |
|
image.avatar | |
`{{faker 'image.avatar' }}` | `https://s3.amazonaws.com/uifaces/faces/twitter/shoaib253/128.jpg` |
Generates a random avatar link. | ----- |
image.imageUrl | |
`{{faker 'image.imageUrl' 640 480 'flowers' true true }}` | `https://placeimg.com/640/480/flowers?77652` |
Generates a random image URL. |
|
image.abstract | |
`{{faker 'image.abstract' 640 480 true }}` | `http://placeimg.com/640/480/abstract?10498` |
Generates a random abstract image link. |
|
image.animals | |
`{{faker 'image.animals' 640 480 true }}` | `http://placeimg.com/640/480/animals?29284` |
Generates a random animal image link. |
|
image.business | |
`{{faker 'image.business' 640 480 true }}` | `http://placeimg.com/640/480/business?29284` |
Generates a random business image link. |
|
image.cats | |
`{{faker 'image.cats' 640 480 true }}` | `http://placeimg.com/640/480/cats?29284` |
Generates a random cat image link. |
|
image.city | |
`{{faker 'image.city' 640 480 true }}` | `http://placeimg.com/640/480/city?29284` |
Generates a random city image link. |
|
image.food | |
`{{faker 'image.food' 640 480 true }}` | `http://placeimg.com/640/480/food?29284` |
Generates a random food image link. |
|
image.nightlife | |
`{{faker 'image.nightlife' 640 480 true }}` | `http://placeimg.com/640/480/nightlife?29284` |
Generates a random nightlife image link. |
|
image.fashion | |
`{{faker 'image.fashion' 640 480 true }}` | `http://placeimg.com/640/480/fashion?29284` |
Generates a random fashion image link. |
|
image.people | |
`{{faker 'image.people' 640 480 true }}` | `http://placeimg.com/640/480/people?29284` |
Generates a random people image link. |
|
image.nature | |
`{{faker 'image.nature' 640 480 true }}` | `http://placeimg.com/640/480/nature?29284` |
Generates a random nature image link. |
|
image.sports | |
`{{faker 'image.sports' 640 480 true }}` | `http://placeimg.com/640/480/sports?29284` |
Generates a random sport image link. |
|
image.technics | |
`{{faker 'image.technics' 640 480 true }}` | `http://placeimg.com/640/480/technics?29284` |
Generates a random technology image link. |
|
image.transport | |
`{{faker 'image.transport' 640 480 true }}` | `http://placeimg.com/640/480/transport?29284` |
Generates a random transport image link. |
|
image.dataUri | |
`{{faker 'image.dataUri' }}` | `data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns...` |
Generates a random data URI image. |
|
internet.avatar | |
`{{faker 'internet.avatar' }}` | `https://s3.amazonaws.com/uifaces/faces/twitter/pierre_nel/128.jpg` |
Generates a random avatar image link. | ----- |
internet.email | |
`{{faker 'internet.email'}}` | `John.Doe12@company.com` |
Generates a random email address. |
|
internet.exampleEmail | |
`{{faker 'internet.exampleEmail' }}` | `John.Doe@example.net` |
Generates a random in domain of 'example.net' |
|
internet.userName | |
`{{faker 'internet.userName' }}` | `Vince.Abshire` |
Generates a random username. |
|
internet.protocol | |
`{{faker 'internet.protocol' }}` | `http` |
Generates a random protocol. | ----- |
internet.url | |
`{{faker 'internet.url' }}` | `http://talon.info` |
Generates a random URL. | ----- |
internet.domainName | |
`{{faker 'internet.domainName' }}` | `collin.net` |
Generates a random domain name. | ----- |
internet.domainSuffix | |
`{{faker 'internet.domainSuffix' }}` | `com` |
Generates a random domain suffix. | ----- |
internet.domainWord | |
`{{faker 'internet.domainWord' }}` | `terry` |
Generates a random domain word. | ----- |
internet.ip | |
`{{faker 'internet.ip' }}` | `123.21.100.68` |
Generates a random IP address. | ----- |
internet.ipv6 | |
`{{faker 'internet.ipv6' }}` | `8815:cccb:7749:3f0e:08c5:8baa:0ca0:8f31` |
Generates a random IP V6 address. | ----- |
internet.userAgent | |
`{{faker 'internet.userAgent' }}` | `Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:13.0) Gecko/20100101 Firefox/13.0.6` |
Generates a random user agent statement. | ----- |
internet.color | |
`{{faker 'internet.color 120 130 140' }}` | `#847d6c` |
Generates a random hex color. |
|
internet.mac | |
`{{faker 'internet.mac' ':'}}` | `d2:e1:7f:86:2a:80` |
Generates a random MAC address. |
|
internet.password | |
`{{faker 'internet.password' 10 false }}` | `B94C0tQEqX` |
Generates a random password. |
|
lorem.word | |
`{{faker 'lorem.word' 10 }}` | `nihil` |
Generates a random Lorem word. |
|
lorem.words | |
`{{faker 'lorem.words' 5 }}` | `ut qui repellat reiciendis consequuntur` |
Generates a random Lorem words. |
|
lorem.sentence | |
`{{faker 'lorem.sentence' 5 }}` | `Omnis odit consectetur assumenda et.` |
Generates a random Lorem sentence. |
|
lorem.slug | |
`{{faker 'lorem.slug' 3}}` | `voluptatem-amet-deleniti-earum-sit` |
Generates a random Lorem slug. |
|
lorem.sentences | |
`{{faker 'lorem.sentences' 3 }}` | `Sed et voluptate animi. Voluptatibus asperiores quis fugit labore soluta ipsum eum. Maxime non quo rerum laborum quibusdam consequatur.` |
Generates a random Lorem sentences. |
|
lorem.paragraph | |
`{{faker 'lorem.paragraph' 3 }}` | `Amet beatae aut. Laboriosam error deserunt unde. Quas explicabo omnis mollitia qui corporis sit nemo. Mollitia corporis possimus doloremque asperiores.` |
Generates a random Lorem paragraph. |
|
lorem.paragraphs | |
`{{faker 'lorem.paragraphs' 1 }}` | `Ipsam suscipit eaque exercitationem et delectus inventore molestiae omnis. Optio repellat nisi natus voluptas sequi. Accusantium quo deleniti esse est.` |
Generates a random Lorem paragraphs. |
|
lorem.text | |
`{{faker 'lorem.text' 1 }}` | `Aut repellendus facilis. Aspernatur expedita aut quibusdam eaque praesentium aut id id...` |
Generates a random Lorem text. | ----- |
lorem.lines | |
`{{faker 'lorem.lines' 1}}` | ` A modi praesentium enim dolores.` |
Generates a random Lorem lines. |
|
name.firstName | |
`{{faker 'name.firstName' 'female' }}` | `Libby` |
Generates a random first name. |
|
name.lastName | |
`{{faker 'name.lastName' }}` | `Goodwin` |
Generates a random last name. |
|
name.findName | |
`{{faker 'name.findName' }}` | `Muriel Cruickshank` |
Generates a random full name. |
|
name.jobTitle | |
`{{faker 'name.jobTitle' }}` | `Dynamic Functionality Associate` |
Generates a random job title. | ----- |
name.gender | |
`{{faker 'name.gender' }}` | `Female` |
Generates a random gender. | ----- |
name.prefix | |
`{{faker 'name.prefix' }}` | `Miss` |
Generates a random name prefix. |
|
name.suffix | |
`{{faker 'name.suffix' }}` | `Jr.` |
Generates a random name suffix. | ----- |
name.title | |
`{{faker 'name.title' }}` | `Corporate Web Strategist` |
Generates a random personal title. | ----- |
name.jobDescriptor | |
`{{faker 'name.jobDescriptor' }}` | `Regional` |
Generates a random job descriptor. | ----- |
name.jobArea | |
`{{faker 'name.jobArea' }}` | `Operations` |
Generates a random job area. | ----- |
name.jobType | |
`{{faker 'name.jobType' }}` | `Administrator` |
Generates a random job type. | ----- |
phone.phoneNumber | |
`{{faker 'phone.phoneNumber' '(!##) !##-####' }}` | `(450) 718-7354` |
Generates a random phone number. |
|
phone.phoneFormats | |
`{{faker 'phone.phoneFormats' }}` | `1-!##-!##-#### x###` |
Generates a random phone format. | ----- |
random.number | |
`{{faker 'random.number' min=0 max=999 precision=0.1 }}` | `531.4` |
Generates a random number. |
|
random.float | |
`{{faker 'random.float' precision=0.01 }}` | `24431.75` |
Generates a random float number. |
|
random.arrayElement | |
`{{faker 'random.arrayElement' (JSONparse '[1,2,3,4,5]') }}` | `4` |
Selects a random array element. |
|
random.arrayElements | |
`{{JSONstringify (faker 'random.arrayElements' (JSONparse '[1,2,3,4,5]') 3 )}}` | `[2,4,5]` |
Selects a random subarray. |
|
random.objectElement | |
`{{faker 'random.objectElement' (JSONparse '{ "foo": "bar", "too": "car" }')}}` | `bar` |
Selects a random object element. |
|
random.uuid | |
`{{faker 'random.uuid' }}` | `ce8ab5db-e03c-48bc-bacb-152efc214b1b` |
Generates a random UUID. | ----- |
random.boolean | |
`{{faker 'random.boolean' }}` | `true` |
Generates a random boolean. | ----- |
random.word | |
`{{faker 'random.word' }}` | `envisioneer` |
Generates a random word. |
|
random.words | |
`{{faker 'random.words' 5 }}` | `SMTP Berkshire Incredible Concrete Mouse protocol Jordan` |
Generates a random words. |
|
random.image | |
`{{faker 'random.image' }}` | `http://placeimg.com/640/480/cats` |
Generates a random image URL. | ----- |
random.locale | |
`{{faker 'random.locale' }}` | `en` |
Generates a random locale. | ----- |
random.alpha | |
`{{faker 'random.alpha' count=10 upcase=true }}` | `ZPKHASSAPD` |
Generates a random alphabetic string. |
|
random.alphaNumeric | |
`{{faker 'random.alphaNumeric' 5 }}` | `6tpyo` |
Generates a random alphanumeric string. |
|
random.hexaDecimal | |
`{{faker 'random.hexaDecimal'5 }}` | `0xe6e36` |
Generates a random hexadecimal number. |
|
system.fileName | |
`{{faker 'system.fileName' }}` | `hong_kong_dollar.karbon` |
Generates a random file name. | ----- |
system.commonFileName | |
`{{faker 'system.commonFileName' }}` | `4th_generation_parsing.m1v` |
Generates a random common file name. | ----- |
system.mimeType | |
`{{faker 'system.mimeType' }}` | ` text/1d-interleaved-parityfec` |
Generates a random mime type. | ----- |
system.commonFileType | |
`{{faker 'system.commonFileType' }}` | `video` |
Generates a random common file type. | ----- |
system.commonFileExt | |
`{{faker 'system.commonFileExt' }}` | `application/pdf` |
Generates a random common file extension. | ----- |
system.fileType | |
`{{faker 'system.fileType' }}` | `chemical` |
Generates a random file type. | ----- |
system.fileExt | |
`{{faker 'system.fileExt' }}` | `snf` |
Generates a random file extension. | ----- |
system.directoryPath | |
`{{faker 'system.directoryPath' }}` | `/var/mail` |
Generates a random durectory path. | ----- |
system.filePath | |
`{{faker 'system.filePath' }}` | `/var/spool/pula_optical.z7` |
Generates a random file path. | ----- |
system.semver | |
`{{faker 'system.semver' }}` | `5.9.3` |
Generates a random semantic version. | ----- |
time.recent | |
`{{faker 'time.recent' 'abbr' }}` | `3:39:12 PM` |
Generates a random recent time. |
|
vehicle.vehicle | |
`{{faker 'vehicle.vehicle' }}` | `Cadillac Altima` |
Generates a random vehicle. | ----- |
vehicle.manufacturer | |
`{{faker 'vehicle.manufacturer' }}` | `Mini` |
Generates a random vehicle manufacturer. | ----- |
vehicle.model | |
`{{faker 'vehicle.model' }}` | `Aventador` |
Generates a random vehicle model. | ----- |
vehicle.type | |
`{{faker 'vehicle.type' }}` | `Wagon` |
Generates a random vehicle type. | ----- |
vehicle.fuel | |
`{{faker 'vehicle.fuel' }}` | `Electric` |
Generates a random fuel name. | ----- |
vehicle.vin | |
`{{faker 'vehicle.vin' }}` | `ICSGO2TLAILJ88512` |
Generates a random vehicle VIN number. | ----- |
vehicle.color | |
`{{faker 'vehicle.color' }}` | `ivory` |
Generates a random vehicle color. | ----- |
Log helper¶
log ...arguments
- allows for logging of context state while executing a template. Logged messages are available in the
workspace's Request Log
Example 1
Request body:
{"name" : "John", "surname": "Doe"}
Template:
{{~log 'Request body is: ' req.body~}}
Logged message:
2020-05-27T13:17:04.963Z - Request body is: {"name" : "John", "surname": "Doe"}
JSON Path Helper¶
jsonPathGet '<path>' object
- Evaluates JSONPath expression. JSONPath is a query language for JSON, similar to XPath for XML.
This helper allows extracting data from a JSON object. See more about JSONPath.
Parameter | Description | Default value |
---|---|---|
path | Valid JSONPath expression Tester. If path is incorrect empty string will be returned. | none |
object | JS object to extract data from. You may use JSONparse helper to parse string to JS object. |
none |
Example 1
Request body:
{"name" : "John", "surname": "Doe"}
Template:
{{jsonPathGet '$.name' (JSONparse req.body) }}
Rendered response body:
John
Other helpers¶
Next to the set of helpers described above template mocks also support the following third-party helpers provided by the project handlebars-helpers:
array helpers - (Documentation) | |
{{after}} |
Returns all of the items in an array after the specified index. |
{{arrayify}} |
Cast the given value to an array. |
{{before}} |
Return all of the items in the collection before the specified count. Opposite of after. |
{{eachIndex}} |
|
{{filter}} |
Block helper that filters the given array and renders the block for values that evaluate to true, otherwise the inverse block is returned. |
{{first}} |
Returns the first item, or first n items of an array. |
{{forEach}} |
Iterates over each item in an array and exposes the current item in the array as context to the inner block. |
{{inArray}} |
Block helper that renders the block if an array has the given value. Optionally specify an inverse block to render when the array does not have the given value. |
{{isArray}} |
Returns true if value is an es5 array. |
{{itemAt}} |
Returns the item from array at index idx. |
{{join}} |
Join all elements of array into a string, optionally using a given separator. |
{{equalsLength}} |
Returns true if the the length of the given value is equal to the given length. Can be used as a block or inline helper. |
{{last}} |
Returns the last item, or last n items of an array or string. Opposite of first. |
{{length}} |
Returns the length of the given string or array. |
{{lengthEqual}} |
Alias for equalsLength |
{{pluck}} |
Map over the given object or array or objects and create an array of values from the given prop. Dot-notation may be used (as a string) to get nested properties. |
{{reverse}} |
Reverse the elements in an array, or the characters in a string. |
{{some}} |
Block helper that returns the block if the callback returns true for some value in the given array. |
{{sort}} |
Sort the given array. If an array of objects is passed, you may optionally pass a key to sort on as the second argument. You may alternatively pass a sorting function as the second argument. |
{{sortBy}} |
Sort an array. If an array of objects is passed, you may optionally pass a key to sort on as the second argument. You may alternatively pass a sorting function as the second argument. |
{{withAfter}} |
Use the items in the array after the specified index as context inside a block. Opposite of withBefore. |
{{withBefore}} |
Use the items in the array before the specified index as context inside a block. Opposite of withAfter. |
{{withFirst}} |
Use the first item in a collection inside a handlebars block expression. Opposite of withLast. |
{{withGroup}} |
Block helper that groups array elements by given group size. |
{{withLast}} |
Use the last item or n items in an array as context inside a block. Opposite of withFirst. |
{{withSort}} |
Block helper that sorts a collection and exposes the sorted collection as context inside the block. |
{{unique}} |
Block helper that return an array with all duplicate values removed. Best used along with a each helper. |
collection helpers - (Documentation) | |
{{isEmpty}} |
Inline, subexpression, or block helper that returns true (or the block) if the given collection is empty, or false (or the inverse block, if supplied) if the colleciton is not empty. |
comparison helpers - (Documentation) | |
{{and}} |
Helper that renders the block if both of the given values are truthy. If an inverse block is specified it will be rendered when falsy. Works as a block helper, inline helper or subexpression. |
{{compare}} |
Render a block when a comparison of the first and third arguments returns true. The second argument is the arithemetic operator to use. You may also optionally specify an inverse block to render when falsy. |
{{contains}} |
Block helper that renders the block if collection has the given value, using strict equality (===) for comparison, otherwise the inverse block is rendered (if specified). If a startIndex is specified and is negative, it is used as the offset from the end of the collection. |
{{default}} |
Returns the first value that is not undefined, otherwise the "default" value is returned. |
{{eq}} |
Block helper that renders a block if a is equal to b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value. |
{{gt}} |
Block helper that renders a block if a is greater than b. |
{{gte}} |
Block helper that renders a block if a is greater than or equal to b. |
{{has}} |
Block helper that renders a block if value has pattern. If an inverse block is specified it will be rendered when falsy. |
{{isFalsey}} |
Returns true if the given value is falsey. Uses the falsey library for comparisons. Please see that library for more information or to report bugs with this helper. |
{{isTruthy}} |
Returns true if the given value is truthy. Uses the falsey library for comparisons. Please see that library for more information or to report bugs with this helper. |
{{ifEven}} |
Return true if the given value is an even number. |
{{ifNth}} |
Conditionally renders a block if the remainder is zero when a operand is divided by b. If an inverse block is specified it will be rendered when the remainder is not zero. |
{{ifOdd}} |
Block helper that renders a block if value is an odd number. If an inverse block is specified it will be rendered when falsy. |
{{is}} |
Block helper that renders a block if a is equal to b. If an inverse block is specified it will be rendered when falsy. Similar to eq but does not do strict equality. |
{{isnt}} |
Block helper that renders a block if a is not equal to b. If an inverse block is specified it will be rendered when falsy. Similar to unlessEq but does not use strict equality for comparisons. |
{{lt}} |
Block helper that renders a block if a is less than b. |
{{lte}} |
Block helper that renders a block if a is less than or equal to b. |
{{neither}} |
Block helper that renders a block if neither of the given values are truthy. If an inverse block is specified it will be rendered when falsy. |
{{not}} |
Returns true if val is falsey. Works as a block or inline helper. |
{{or}} |
Block helper that renders a block if any of the given values is truthy. If an inverse block is specified it will be rendered when falsy. |
{{unlessEq}} |
Block helper that always renders the inverse block unless a is is equal to b. |
{{unlessGt}} |
Block helper that always renders the inverse block unless a is is greater than b. |
{{unlessLt}} |
Block helper that always renders the inverse block unless a is is less than b. |
{{unlessGteq}} |
Block helper that always renders the inverse block unless a is is greater than or equal to b. |
{{unlessLteq}} |
Block helper that always renders the inverse block unless a is is less than or equal to b. |
html helpers - (Documentation) | |
{{attr}} |
Stringify attributes on the options hash. |
{{sanitize}} |
Strip HTML tags from a string, so that only the text nodes are preserved. |
{{ul}} |
Block helper for creating unordered lists ( |
{{ol}} |
Block helper for creating ordered lists ( |
inflection helpers - (Documentation) | |
{{inflect}} |
Returns either the singular or plural inflection of a word based on the given count. |
{{ordinalize}} |
Returns an ordinalized number as a string. |
math helpers - (Documentation) | |
{{abs}} |
Return the magnitude of a. |
{{add}} |
Return the sum of a plus b. |
{{avg}} |
Returns the average of all numbers in the given array. |
{{ceil}} |
Get the Math.ceil() of the given value. |
{{divide}} |
Divide a by b |
{{floor}} |
Get the Math.floor() of the given value. |
{{minus}} |
Return the difference of a minus b. |
{{modulo}} |
Get the remainder of a division operation. |
{{multiply}} |
Return the product of a times b. |
{{plus}} |
Add a by b. |
{{random}} |
Generate a random number between two values |
{{remainder}} |
Get the remainder when a is divided by b. |
{{round}} |
Round the given number. |
{{subtract}} |
Return the product of a minus b. |
{{sum}} |
Returns the sum of all numbers in the given array. |
{{times}} |
Multiply number a by number b. |
misc helpers - (Documentation) | |
{{option}} |
Return the given value of prop from this.options . |
{{noop}} |
Block helper that renders the block without taking any arguments. |
{{typeOf}} |
Get the native type of the given value |
{{withHash}} |
Block helper that builds the context for the block from the options hash. |
number helpers - (Documentation) | |
{{bytes}} |
Format a number to it's equivalent in bytes. If a string is passed, it's length will be formatted and returned. |
{{addCommas}} |
Add commas to numbers |
{{phoneNumber}} |
Convert a string or number to a formatted phone number. |
{{toAbbr}} |
Abbreviate numbers to the given number of precision. This is for general numbers, not size in bytes. |
{{toExponential}} |
Returns a string representing the given number in exponential notation. |
{{toFixed}} |
Formats the given number using fixed-point notation. |
{{toFloat}} |
|
{{toInt}} |
|
{{toPrecision}} |
Returns a string representing the Number object to the specified precision. |
object helpers - (Documentation) | |
{{extend}} |
Extend the context with the properties of other objects. A shallow merge is performed to avoid mutating the context. |
{{forIn}} |
Block helper that iterates over the properties of an object, exposing each key and value on the context. |
{{forOwn}} |
Block helper that iterates over the own properties of an object, exposing each key and value on the context. |
{{toPath}} |
Take arguments and, if they are string or number, convert them to a dot-delineated object property path. |
{{get}} |
Use property paths (a.b.c ) to get a value or nested value from the context. Works as a regular helper or block helper. |
{{getObject}} |
Use property paths (a.b.c ) to get an object from the context. Differs from the get helper in that this helper
will return the actual object, including the given property key. Also, this helper does not work as a block helper. |
{{hasOwn}} |
Return true if key is an own, enumerable property of the given context object. |
{{isObject}} |
Return true if value is an object. |
{{JSONparse}} |
Parses the given string using JSON.parse . |
{{JSONstringify}} |
Stringify an object using JSON.stringify . |
{{merge}} |
Deeply merge the properties of the given objects with the context object. |
{{pick}} |
Pick properties from the context object. |
regex helpers - (Documentation) | |
{{toRegex}} |
Convert the given string to a regular expression. |
{{test}} |
Returns true if the given str matches the given regex. A regex can be passed on the context, or using the toRegex helper as a subexpression. |
string helpers - (Documentation) | |
{{append}} |
Append the specified suffix to the given string. |
{{camelcase}} |
camelCase the characters in the given string. |
{{capitalize}} |
Capitalize the first word in a sentence. |
{{capitalizeAll}} |
Capitalize all words in a string. |
{{center}} |
Center a string using non-breaking spaces |
{{chop}} |
Like trim, but removes both extraneous whitespace and non-word characters from the beginning and end of a string. |
{{dashcase}} |
dash-case the characters in string. Replaces non-word characters and periods with hyphens. |
{{dotcase}} |
dot.case the characters in string. |
{{downcase}} |
Lowercase all of the characters in the given string. Alias for lowercase. |
{{ellipsis}} |
Truncates a string to the specified length, and appends it with an elipsis, …. |
{{hyphenate}} |
Replace spaces in a string with hyphens. |
{{isString}} |
Return true if value is a string. |
{{lowercase}} |
Lowercase all characters in the given string. |
{{occurrences}} |
Return the number of occurrences of substring within the given string. |
{{pascalcase}} |
PascalCase the characters in string. |
{{pathcase}} |
path/case the characters in string. |
{{plusify}} |
Replace spaces in the given string with pluses. |
{{prepend}} |
Prepends the given string with the specified prefix. |
{{raw}} |
Render a block without processing mustache templates inside the block. |
{{remove}} |
Remove all occurrences of substring from the given str. |
{{removeFirst}} |
Remove the first occurrence of substring from the given str. |
{{replace}} |
Replace all occurrences of substring a with substring b. |
{{replaceFirst}} |
Replace the first occurrence of substring a with substring b. |
{{reverse}} |
Reverse a string. |
{{sentence}} |
Sentence case the given string |
{{snakecase}} |
snake_case the characters in the given string. |
{{split}} |
Split string by the given character. |
{{startsWith}} |
Tests whether a string begins with the given prefix. |
{{titleize}} |
Title case the given string. |
{{trim}} |
Removes extraneous whitespace from the beginning and end of a string. |
{{trimLeft}} |
Removes extraneous whitespace from the beginning of a string. |
{{trimRight}} |
Removes extraneous whitespace from the end of a string. |
{{truncate}} |
Truncate a string to the specified length. Also see ellipsis. |
{{truncateWords}} |
Truncate a string to have the specified number of words. Also see truncate. |
{{upcase}} |
Uppercase all of the characters in the given string. Alias for uppercase. |
{{uppercase}} |
Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks. |
url helpers - (Documentation) | |
{{encodeURI}} |
Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. |
{{escape}} |
Escape the given string by replacing characters with escape sequences. Useful for allowing the string to be used in a URL, etc. |
{{decodeURI}} |
Decode a Uniform Resource Identifier (URI) component. |
{{urlResolve}} |
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. |
{{urlParse}} |
Parses a url string into an object. |
{{stripQuerystring}} |
Strip the query string from the given url. |
{{stripProtocol}} |
Strip protocol from a url. Useful for displaying media that may have an 'http' protocol on secure connections. |
|