rustysan-sword 0.1.1

Blade-inspired HTML templates for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
title: Template diagnostics
weight: 14
---

Sword carries source spans through translation. For a broken nested view, a standalone error can look like:

```text
orders.row:2: undefined value (column 7)
  source: resources/views/orders/row.sword.html:2:7
  called from resources/views/orders/index.sword.html:5:1
```

The `Error::Render` fields retain the logical template name and original line. The message includes the original file path when the view was loaded from a root, an exact column when it can be mapped reliably, and include, layout, component, or caller-slot context when available. `render_source` uses the supplied name because it has no file path. Laravel's `TemplateError` exposes the failing file and line; any column and call sites are in its message.

Copied expressions and supported translated constructs have source-span mappings. An error in generated code without a reliable exact mapping is attributed to its original directive or tag without an invented column; that location can be approximate within a multiline construct. If the backend supplies no mappable location, Sword returns `Error::RenderUnlocated` rather than guessing a line. Caller traces depend on the information available at the failure. Source mappings are per render and contain template source, not request data.