# Add view helpers and read the config in views

> Register functions in DEF.helpers to call them from views, and read config values with @{'%key'}.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: en
Content-SHA256: 21035b147dccc83278a6a3e3d128e697c065d93638b9972b1cd8fb9d7b7c6583
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Functions registered in `DEF.helpers` are available in every view as `helpers.name(...)`. Use them for formatting that you repeat (prices, dates, labels).

Settings from the `config` file are printed with `@{'%key'}`, for example `@{'%name'}` for the `name` setting, so the view does not need access to `CONF`.

```text config
name : Forge shop
```

```js definitions/helpers.js
DEF.helpers.price = function(value) {
	return '$' + value.toFixed(2);
};
```

```html views/index.html
@{layout('')}
<h1>@{'%name'}</h1>
<p class="price">@{helpers.price(model.price)}</p>
```

```js controllers/default.js
exports.install = function() {
	ROUTE('GET /', page);
};

function page($) {
	$.view('index', { price: 9.5 });
}
```
