Skip to main content

URL Operators

When we need to work with urls, these operators will help with your markdown.

List of Operators

{{ 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.

Params

  • str : The un-encoded string
  • returns : The endcoded string

{{ escape }}

Escape the given string by replacing characters with escape sequences. Useful for allowing the string to be used in a URL, etc.

Params

  • str
  • returns : Escaped string.

{{ decodeURI }}

Decode a Uniform Resource Identifier (URI) component.

Params

  • str
  • returns

{{ url_encode }}

Alias for encodeURI.

{{ url_decode }}

Alias for decodeURI.

{{ urlResolve }}

Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.

Params

  • base
  • href
  • returns

{{ urlParse }}

Parses a url string into an object.

Params

  • str : URL string
  • returns : Returns stringified JSON

{{ stripQuerystring }}

Strip the query string from the given url.

Params

  • url
  • returns : the url without the queryString

{{ stripProtocol }}

Strip protocol from a url. Useful for displaying media that may have an 'http' protocol on secure connections.

Params

  • str
  • returns : the url with http protocol stripped

Example

<!-- url = 'http://foo.bar' -->
{{stripProtocol url}}
<!-- results in: '//foo.bar' -->