ComboStrap UI - Pipeline

About

A pipeline is a element that contains a list of function (called a pipeline) that transforms successively a string.

Pipeline are used in template when you want to transform a variable such as a page title.

Syntax

<pipeline> value | function | function | ... </pipeline>

where:

  • value is the string to transform or a template variable
  • function is one of:
    • replace - replace a string
    • rconcat - add a string at the right side
    • head - return the first characters
    • cut - cut the string in parts and return one
    • trim - delete any space before and after

Functions

Replace

replace is a function that will search a string and replace it.

Syntax:

replace($search, $replace)

For instance:

<pipeline> "Prefix - Title" | replace("Prefix - ","") </pipeline>

Output:

Title

Rconcat

rconcat is a function that will concatenate a string to the right

Syntax:

rconcat($string)

For instance:

<pipeline> "Title" | rconcat("...") </pipeline>

Output:

Title...

head is a function that will take the fist N characters of a string

Syntax:

head($length)

For instance:

<pipeline> "Long Title that we want to cut" | head(10) | rconcat("...") </pipeline>

Output:

Long Title...

Cut

cut is a function that will split the string in parts and returned the asked part concatenated. If the separator is not found, the original string is returned

Syntax:

cut("separator",partIndex)

where:

  • separator can be a simple character or a regular expression.
  • partIndex is the part number (starts at 1 for the first one)

Example:

  • Basic
<pipeline> "Hello - World" | cut("-",2) </pipeline>

Output:

World

  • if the separator is not found, the function has not effect on the string given.
<pipeline> "Hello World" | cut("-",2) </pipeline>

Output:

Hello World

Trim

trim is a function that strip whitespace from the beginning and end of a string

Syntax:

trim()

For instance:

<pipeline> "Hello World   " | trim() </pipeline>

Output:

Hello World

Powered by ComboStrap