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

Implemented async attributes and content. #428

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

radekmie
Copy link
Collaborator

@radekmie radekmie commented Nov 4, 2023

This is an extension of #424, where both async attributes and content are now supported. That means the following code is now correct:

Template.example.helpers({
  getClass: async () => 'dynamic',
  getContent: async () => 'Hello there!',
});
<template name="example">
  <span class="static {{getClass}}">{{getContent}}</span>
</template>

Just like the #if and #each in #424, nothing is rendered until resolved. There's only one problem with async content - since a new view is created each time, the value may flicker. I decided to leave it for now and look into it later.


Note that async spread attributes, e.g., <img {{attributes}}> are NOT supported yet.

@radekmie radekmie added this to the Blaze 3.0 milestone Nov 4, 2023
Copy link
Collaborator

@StorytellerCZ StorytellerCZ left a comment

Choose a reason for hiding this comment

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

LGTM

@DanielDornhardt
Copy link

DanielDornhardt commented Nov 14, 2023

Hi guys! This is important stuff for templates forward compatibility with async / prepping code for Async / Meteor 3.0 in Meteor 2.x. Any chance that this'll be merged soon & possibly be included in the 2.14 release?

It's this PR and this one: Added support for Promises in #if and #each which would be important I think.

The previous one [https://github.com//pull/424](Added support for Promises in #if and #each) we're running in our fairly big meteor blaze app for some weeks now & it looks like it has no bad side effects on existing code as well as doing what it's supposed to do.

This one I could try to give a shake this week as well in our codebase.

What do you think @StorytellerCZ @Grubba27 @radekmie ?

@StorytellerCZ
Copy link
Collaborator

@jankapunkt @radekmie I leave this to you guys to figure out if it is ready to merge. I'm happy to get all the async stuff merged and release an alpha of Blaze 3.

Copy link
Contributor

@Grubba27 Grubba27 left a comment

Choose a reason for hiding this comment

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

lgtm

@Grubba27 Grubba27 merged commit c6bdf78 into async-if-each Nov 16, 2023
2 checks passed
@StorytellerCZ StorytellerCZ deleted the async-attributes-and-content branch November 16, 2023 19:33
@radekmie
Copy link
Collaborator Author

@Grubba27 This PR was supposed to be merged later 🙈

@Grubba27
Copy link
Contributor

Sorry 😢 I thought we were merging those PRs.
Would like me to revert those changes?

@radekmie
Copy link
Collaborator Author

No, it's all good. I just wanted to merge them in the opposite order, so their diffs would be meaningful - now this one includes the other one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Being worked on
Development

Successfully merging this pull request may close these issues.

4 participants