Skip to content

Commit e79c39c

Browse files
authored
chore: update on functionality of cot::reverse in docs (#73)
1 parent 148de32 commit e79c39c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

templates.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ Rendered output:
148148

149149
Linking to other pages in your application is a frequent requirement, and hardcoding URLs in templates can become a maintenance hassle. To address this, Cot provides the `cot::reverse!()` macro. This macro generates URLs based on your route definitions, validating that you’ve passed any required parameters and that the route actually exists. If you ever change your URL structure, you'll only need to update the route definitions.
150150

151-
`cot::reverse!()` expects a reference to the `Urls` object (which you can obtain by extracting it from the request), the route name, and any parameters needed by that route.
151+
`cot::reverse!()` expects a reference to the `Urls` object (which you can obtain by extracting it from the request), the route name, and any parameters needed by that route. It returns a `Result<String, Error>`, so should be suffixed by "?" when used in the html template.
152152

153153
### Example
154154

155155
`index.html`:
156156

157157
```html.j2
158158
{% let urls = urls %}
159-
<a href="{{ cot::reverse!(urls, "index") }}">Home</a>
160-
<a href="{{ cot::reverse!(urls, "user", id=42) }}">User 42</a>
159+
<a href="{{ cot::reverse!(urls, "index")? }}">Home</a>
160+
<a href="{{ cot::reverse!(urls, "user", id=42)? }}">User 42</a>
161161
```
162162

163163
`main.rs`:

0 commit comments

Comments
 (0)