# Lattenizer

Unfortunately, it is not process of latte coffee preparation. 😦

Lattenizer is tool for transforming templates (Latte/Markdown) into HTML.


Variable hello is world.

Latte template:

Hello {$hello}
1

Transformed template:

Hello world!
1

Lattenizer has 2 requirements: user input and variables.

User (yours) input is defined in process templates and variables are defined here.

# Integration

You can use Lattenizer in, these panels:

  • templater (template)
  • email (subject, content)
  • adminus customer detail (template)
  • adminus contract detail (template)

These callbacks:

  • email (subject, content)

It's also used in:

  • inbox field from process template

# Snippets

General snippets (defined in administration) or process snippets (defined in process template) can be included inside latte template. If both process and general snippets exists with same name, process snippet is used.

Notice that .snippet suffix is required.

{include 'snippetName.snippet', name=>'Adam'}
1

# Syntax

# Variables

{$variable} prints variable

{$variable|upper} applies filter upper and prints variable

{=expression} prints expression

{var $variable = 'Author'} defines variable

{default $variable = 'Book'} defines variable if variable isn't declared

{capture $variable} Long section {/capture} captures a section to a variable

# Cycles

{foreach $users as $user}
	{$user->name}
{/foreach}
1
2
3

# Conditions

{if $isActivated}
	Contact is alive!
{else}
	Contract is blocked!
{/if}
1
2
3
4
5

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

Method Scope Description
$_linker->detailLink($id) panels, callbacks Creates link to the process detail.
$_linker->nextLink() panels Creates link to move process to the next step.
$_linker->nextAllowed() panels Returns true/false if you're able to move process to the next step.

Examples

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

# Deprecated

<a target="_blank" href="{lotuslink process-detail $id}">Link to process detail</a>
1

# Filters

Filters modify input before printing. Filters with with UTF-8 encoded strings.

# List of available filters

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"/>
markdown Formats input as markdown {= '**Joe**'|markdown} Joe
jmespath Parse structure by jmespath {= [['name' => 'Joe']]|jmespath:'[0].name'} Joe

# 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)}

# Applying filter to block

Formatting expressions can be done by capturing input to block and then filtering whole block.

{block|stripHtml|markdown}
    # {$header}

    - {$ad1}
    - {$ad2}
    - {$ad3}

    *Rendered* **{=date('m/d/Y')}**
{/}
1
2
3
4
5
6
7
8
9

# Errors

# Undefined

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