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

issue of adding methods #18

Open
liigo opened this issue Dec 12, 2024 · 3 comments
Open

issue of adding methods #18

liigo opened this issue Dec 12, 2024 · 3 comments

Comments

@liigo
Copy link

liigo commented Dec 12, 2024

#[derive(Template)]
#[template(ext = "html")]
// in the preview, the `source="…"` or `path="…"` argument is provided for you
struct HelloWorld<'a> {
    user: &'a str,
    first_visit: bool,
}

impl<'a> HelloWorld<'a> {
    fn user_name(&self) -> &str { self.user }
}

After adding impl HelloWorld item, play-rinja report "unexpected token" compiler error:

const _: () = {
    extern crate rinja as rinja;
    rinja::helpers::core::compile_error!("unexpected token");
};
@Kijewski
Copy link
Collaborator

Kijewski commented Dec 12, 2024

/edit: Oops, I just saw that the repo is play-rinja, not rinja. But the answer stays the same. :)

The // in the preview, the `source="…"` or `path="…"` argument is provided for you part tells me that you are using the playground? In there you can only paste your struct, no implementation or further code. Because a derive macro cannot see anything but the struct definition, any other code would not change the generated template code, anyway. You can simply omit it; the code stays the same (in the preview).

@liigo
Copy link
Author

liigo commented Dec 12, 2024

@Kijewski I see. Thank you. Closing.

@liigo liigo closed this as completed Dec 12, 2024
@liigo
Copy link
Author

liigo commented Dec 12, 2024

sorry ... i reopen it ... just to see ... maybe we can fix it?

@liigo liigo reopened this Dec 12, 2024
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

No branches or pull requests

2 participants