Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown filter requires markdown feature error, even though the feature is enabled #656

Closed
Asha20 opened this issue Mar 29, 2022 · 6 comments

Comments

@Asha20
Copy link

Asha20 commented Mar 29, 2022

Hey, I'm not sure if I'm doing something wrong here or it's a bug, but I can't seem to get the markdown filter working, even though the relevant feature is enabled; I keep getting a proc macro compile error. Any help would be greatly appreciated!

My code looks something like this:

src/main.rs

use askama::Template;

#[derive(Template)]
#[template(path = "basic.jinja")]
struct BasicTemplate {
    content: String,
}

fn main() {}

templates/basic.jinja

{{ content|markdown }}

Cargo.toml

[package]
name = "demo"
version = "0.1.0"
edition = "2021"

[dependencies]
askama = { version = "0.11.1", features = ["markdown"] }
@Kijewski
Copy link
Collaborator

Huh, I can reproduce the error, but I can't see the reason. Even if I explicitly depend on askama_shared/markdown it does not work.

[dependencies.askama_shared]
features = ["markdown"]

I don't see a typo or anything, and hd does not show any stray zero-width characters. @djc, do you have an idea?

@djc
Copy link
Collaborator

djc commented Mar 30, 2022

Yes! Here's a hint: if you change the edition to 2018, it fails with a different error (that we should probably fix):

move occurs because `self.content` has type `String`, which does not implement the `Copy` trait

So here's what's happening: in 2021 Cargo defaults to the new resolver, which compiles dependencies separately if they have different features. With the recent changes, we no longer forward Cargo features through askama_derive to askama_shared, which means that, while run-time askama_shared has the markdown feature (as evidenced by the appearance of the comrak dependency in Cargo.lock), the askama_shared that askama_derive depends on does not.

@genusistimelord
Copy link
Contributor

I will also look into if this is the same as my issue.

@genusistimelord
Copy link
Contributor

yes this is a similar issue I have also fixed it in my tests. Will PR it soon once I'm done running all the tests.

@genusistimelord
Copy link
Contributor

This should be resolved within the PR https://github.com/djc/askama/pull/662. @Asha20 please give it a try. if it now works with the latest git please close this. Thank you.

@Asha20
Copy link
Author

Asha20 commented Apr 27, 2022

Looks like it works now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants