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

Macros for commonly created objects #615

Open
Ciubix8513 opened this issue Mar 31, 2023 · 0 comments
Open

Macros for commonly created objects #615

Ciubix8513 opened this issue Mar 31, 2023 · 0 comments

Comments

@Ciubix8513
Copy link

Is your feature request related to a problem? Please describe.

It is quite a pain to create things like paragraphs or table cells. For example if you need to create a bunch of paragraphs you have to do
Paragraph::new().add_run(Run::new().add_text("Text")); over and over again

Describe the solution you'd like

It would be great if there were macros for that. For example, here's my macro for creating a paragraph:

#[macro_export]
macro_rules! paragraph {
    ($text:expr) => {
        paragraph!($text, AlignmentType::Center)
    };
    ($text:expr,$align:expr) => {
        Paragraph::new()
            .add_run(Run::new().add_text($text))
            .align($align)
    };
}

With this macro i can just do paragraph!("Text"); which is just so much nicer

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

1 participant