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

feat(text): add raw! and styled! macros #4

Merged
merged 1 commit into from
Jan 13, 2024
Merged

feat(text): add raw! and styled! macros #4

merged 1 commit into from
Jan 13, 2024

Conversation

joshka
Copy link
Member

@joshka joshka commented Jan 13, 2024

These macros are similar to the format! macro, but return a raw or
styled Span instead of a String.

use ratatui_macros::{raw, styled};

let name = "world";
raw!("Hello, {name}!");
styled!(Style::new().green(), "Hello, {name}!");
styled!(Color::Green, "Hello, {name}!");
styled!(Modifier::BOLD, "Hello, {name}!");

Copy link
Collaborator

@kdheepak kdheepak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Should we add a note to the README?

@joshka
Copy link
Member Author

joshka commented Jan 13, 2024

Looks good! Should we add a note to the README?

done

These macros are similar to the format! macro, but return a raw or
styled Span instead of a String.

```rust
use ratatui_macros::{raw, styled};

let name = "world";
raw!("Hello, {name}!");
styled!(Style::new().green(), "Hello, {name}!");
styled!(Color::Green, "Hello, {name}!");
styled!(Modifier::BOLD, "Hello, {name}!");
```
@joshka joshka merged commit f33d51e into main Jan 13, 2024
3 checks passed
@joshka joshka deleted the span_macro branch January 13, 2024 08:45
@github-actions github-actions bot mentioned this pull request May 9, 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

Successfully merging this pull request may close these issues.

2 participants