# Σtemplate example 4: callbacks

## 1. Using callbacks for minor presentation changes

Here we use callback function to iterate between two background colors of table cells. The beauty of this example is that all the logic to select the needed color is contained in the script, while the colors themselves are inside the template.

Note also that the callback is called only once per parse() call, that's because all of the calls are identical.

Error code | Error message | Reason | Solution
--- | --- | --- | ---
{code} | {message} | {reason} | {solution}

## 2. Using callbacks for i18n

You can plug in any kind of i18n solution as a callback for 'func_translate'. Note that all the messages are contained in the template and can be edited without touching scripts.

### {language}

- func_translate(Username): {username}
- func_translate(Find all posts by {username})
- func_translate('Send private message')

## 3. Shorthand for callbacks, built-in callbacks

A common problem is to output the same variable, but encoded/processed in different ways. The shorthand {var:callback} for callback functions and default callbacks 'h', 'u' and 'j' were added specifically to address this.

- For output in HTML: {escaped:h}
- For output in URLs: a link
- For javascript:
- Use a custom callback: {escaped:letters}