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:
    • capitalize - make the first letter of each word a capital letter (ie uppercase letter)
    • cut - cut the string in parts and return one
    • head - return the first characters
    • replace - replace a string
    • rconcat - add a string at the right side
    • trim - delete any space before and after

Functions

Capitalize

capitalize is a function that will make the first letter of each word an uppercase letter (ie capital letter)

Syntax:

capitalize()

Example:

<pipeline> "hello foo  bar" | capitalize() </pipeline>

Output:

Hello Foo Bar

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",selector)

where:

  • separator can be a simple character or a regular expression.
  • selector is a token selection in the form x[-y] where:
    • x is the first token to select
    • - will select also the next tokens (optional, if not set only one token is returned)
    • y is the last token to select (optional, by default, the last one)

Example:

  • Range Token Selection. Select all token from the second
<pipeline> "Hello - Foo - Bar" | cut("-","2-") </pipeline>

Output:

Foo - Bar

  • Single Token Selection. Select only the second token
<pipeline> "Hello - Foo - Bar" | cut("-",2) </pipeline>

Output:

Foo

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

Output:

Hello World

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

Rconcat

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

Syntax:

rconcat($string)

For instance:

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

Output:

Title...

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

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