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

Add basic template macro #10

Merged
merged 8 commits into from
Dec 16, 2024
Merged

Conversation

NthTensor
Copy link
Collaborator

@NthTensor NthTensor commented Dec 16, 2024

Adds a very basic declarative template system, with rudimentary incrementalization.

fn hello_to(name: String, party_time: bool) -> Template {
    template! {
        root: { Node::default() } [
            greetings: { TextSpan::new("Hello") };
            name: {
                if !party_time {
                    (TextSpan::new(name), TextColor::default())
                } else {
                    (TextSpan::new(format!("{}!!!!!", name)), TextColor(css::HOT_PINK.into()))
                }
            };
        ];
    }
}

See the included example for a more complete indication of how it works. Caveat emptor!

NthTensor and others added 2 commits December 16, 2024 16:04
Co-authored-by: Joona Aalto <[email protected]>
Co-authored-by: Joona Aalto <[email protected]>
Co-authored-by: Joona Aalto <[email protected]>
@alice-i-cecile alice-i-cecile added the enhancement New feature or request label Dec 16, 2024
Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: Joona Aalto <[email protected]>
Copy link
Contributor

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Can you add a note to the RELEASES.md and bump the version number? Let's ship this :)

@NthTensor
Copy link
Collaborator Author

NthTensor commented Dec 16, 2024

Sweet! I'll let you press the button. (Thanks for the corrections, it looks like maybe my editor's spellcheck has broken).

@alice-i-cecile alice-i-cecile merged commit 886fd45 into Leafwing-Studios:main Dec 16, 2024
This was referenced Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants