# Lattenizer

Lattenizer is powerful language, based on Latte(opens new window) templating language, used in Floweye.

# Demo

  • $hello => world
  • $users => [1, 2, 3]
Lattenizer Output
Hello {$hello}!
Hello world!
{foreach $users as $user} {$user} {/foreach}
1 2 3

# Integration

You can use lattenizer in variant places:

# Syntax

Latte is full-featured templating language, take a first look at official documentation(opens new window) .

Basic syntax is divided into:

  • macros
  • filters
  • text

# Macros

Take a look at default Latte macros(opens new window) .

Macro Example
if / elseif
{if $_process->activeStep->resolver !== null}
	...
{elseif $foo === 1}
	...
{/if}
if (ternary)
{$foo === 1 ? 'yes' : 'no'}
var
{var $foo = 1}
foreach
{foreach $users as $user}
	{$user}
{/foreach}

# Filters

Filters modify input before printing.

Take a look at default Latte filters(opens new window) .

Filter Description Usage Returns
truncate Shortens an input preserving whole words {='Hello'|truncate:5,'...'} He...
substr Returns part of a string {='12345'|substr:1,2} 23
trim Removes whitespace from begging and end {=' Joe '|trim} Joe
striptags Removes HTML tags {='<a>Click</a>'|striptags} Click
strip Removes whitespace {=' Joe Doe '|strip} Joe Doe
indent Indents an input from left with tabs #{='hello'|indent:1,'\t'} # hello
replace Replace all occurrences {='A B C'|replace:' ', '-'} A-B-C
replaceRE Replace all pattern occurrences {='A B C'|replaceRE:'#\s#', '-'} A-B-C
padLeft Completes an input to given length from left {='5'|padLeft:5,'0'} 00005
padRight Completes an input to given length from right {='5'|padRight:5,'0'} 50000
repeat Repeats input given times {='5'|repeat:5} 55555
implode Joins an array to a string {=[5,4,3,2,1]|implode:','} 5,4,3,2,1
webalize Adjusts a string to the shape used in the URL {='Hey I am Joe'|webalize} hey_i_am_joe
breaklines Inserts HTML line breaks before all newlines {='
Hello'|breaklines} <br>Hello
reverse Reverse an array or a string {='Hello'|reverse} olleH
length Returns length of an array or a string {='Hello'|length} 5
lower Makes string lower case {='Hello'|lower} Hello
upper Makes string upper case {='Hello'|upper} HELLO
firstUpper Makes the first letter upper case {='joe'|firstUpper} Joe
capitalize The first letter in each word upper case {='joe DOE'|capitalize} Joe Doe
date Formats date {='2019/05/15'|date:'j.n.Y'} 15.5.2019
toHHMMSS Converts seconds (integer) into HH:MM:SS format {= 3666|toHHMMSS} 01:01:06
uptime Converts seconds (integer) into d h m s {= 3666|uptime} 1h 1m 6s
timeDiff Relative time (translated) from now {= '2019/05/15'|timeDiff} 5 days ago
number Formats number {= 1234.20|number:2:',':' '} 1 234,20
bytes Format size in bytes {= 4664565461|bytes} 4.34 GB
noescape Prints a variable without escaping {= '<div></div>'|noescape} <div></div>
escapeurl Escapes parameter in URL {= '<I\'m>'|escapeurl} %3Cpr%27a%3E
nocheck Prevents automatic URL sanitization href="{='javascript:window.close()'|nocheck}" href="javascript:window.close()"
checkurl Sanitizes string for use inside href attribute href="{='javascript:window.close()'|checkurl}" href=""
neon Formats an input to NEON format {= ['name' => 'Joe']|neon} name: Joe
json Formats an input to JSON format {= ['name' => 'Joe']|json} {"name": "Joe"}
gravatar Generates avatar from email <img src="{$_process->activeStep->resolver->email|gravatar:[size=>48]}"/> <img src="URL"/>
pgravatar Generates avatar from user proxy entity <img src="{$_process->activeStep->resolver|pgravatar:[size=>48]}"/> <img src="URL"/>

# Chaining filters

Formatting input with multiple filters is done by attaching one filter after the other. Filter priority is from left to right.

{= 'foo bar'|replace:' ', '-'|upper} prints FOO-BAR

# Using filters in expression

{var $name = ($title|upper) . ($subtitle|lower)}

# Features

We provide several features special for Floweye developer experience.

You can manually create a link for your buttons or hrefs.

Method Scope Description
$_linker->detailLink($processId) panels, callbacks Creates link to the process detail.
$_linker->nextLink($processId) panels Creates link to move process to the next step.

Examples

<a href="{$_linker->detailLink($_process->id}">Process detail</a>
<a href="{$_linker->detailLink($processes[0]->id)}">Subprocess detail</a>
1
2
<a href="{$_linker->nextLink($_process->id)}">Move next</a>
1

# Functions

List of our functions, previously used in LPL. There are accessible under $_fn object.

Function Description Usage Returns
jmespath Filter structures http://jmespath.org. $_fn->jmespath(data, "[2:5]") [2,3,4]
timeCombine Adds two HH:MM strings. $_fn->timeCombine("1:44","0:20") 02:04
dateDays Returns number of days between two dates $_fn->dateDays("1.1.2019", "2.1.2019") 2 (int)
map Maps values from array. $_fn->map(readers, "fullname") ["FS", "MD"]

If you would like to use function returning arrays, you gonna need {output(<fn>)} macro.

# Output

Sometimes you gonna needed to return array in field that does not support it.

events:
	on_process_start:
		mutate_variable:
			config:
				variables:
					pick_item_input: "{output([key1 => value1, key2 => value2, key3 => value3])}"

steps:
	first:
		layout:
			sections:
				s1:
					panels:
						pick_item__6:
							render: {width: 4}
							config:
								input: "{output($items)}"
								output: somevar
								useKeys: true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

For this use-case you can use macro {output(<data>)}.

# Errors

In case that variable is used incorrectly, e.g. when trying to get non-existing key then warning is rendered:

{$__user->foobar}
1

Rendered warning:

{unknown property foobar}
1