# Server.format(_:for:)

- **Module:** Server
- **Package:** libtmux-swift
- **Language:** Swift
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-swift/blob/254f8b2be7eb60cacc3ffcb3ea8e456784f582df/Sources/LibTmux/Formats.swift#L260
- **Page:** https://libtmux.org/en/swift/latest/reference/server-format(_-for-)/

```
Server.format(_:for:)(template: String, for: Session) -> String?
```

Evaluates a tmux format and hands back what it printed.

The listed types carry the fields worth modelling — a ``Pane`` knows its
id, its size, and what is running in it. tmux publishes hundreds more,
and this reaches any of them without the library having to name each
one first:

Ask for as many fields as you like in one template, separated by
whatever the value cannot contain — a newline is the one separator to
avoid, since a connection reads commands by line and refuses one.

- Returns: what tmux printed, minus the newline it ends every answer
  with, or `nil` when `target` no longer resolves.

## Raises

- `TmuxError`

## Example

```swift
let tty = try await server.format("#{pane_tty}", for: pane, through: link)
```
