Skip to content

Update ref documentation#456

Merged
GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom
sinder38:update-ref-doc
May 26, 2025
Merged

Update ref documentation#456
GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom
sinder38:update-ref-doc

Conversation

@sinder38
Copy link
Copy Markdown
Contributor

Changed as_ref in the book to ref
Add a line about ref renaming to the upgrade guide

Add a line about `ref` renaming to the upgrade guide
@sinder38
Copy link
Copy Markdown
Contributor Author

This is outside the scope of this PR, but I think it would be beneficial to keep as_ref as a usable option for backward compatibility. Something like this could work as a temporary solution:

// filters.rs:45
"as_ref" => {
    eprintln!(
        "Warning: `as_ref` is deprecated and has been renamed to `ref`. Please update your templates."
    );
    Self::visit_ref_filter
}

That said, printing to stderr isn’t ideal. It would be great to emit proper deprecation warnings directly in the template output, for example:

warning: `as_ref` is deprecated and has been renamed to `ref`. Please update your templates.
  ┌─ index.html:12:15
  │
12 │ <p>{{ foo | as_ref }}</p>
  │               ^^^^^^ `as_ref` is deprecated and has been renamed to `ref`. Please update your templates.

However, implementing this kind of contextual warning would likely require some changes to the current code 😑

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit f3201cf into askama-rs:master May 26, 2025
39 checks passed
@Kijewski Kijewski mentioned this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants