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

Eliminate whitespace in Template.dynamic #351

Merged
merged 1 commit into from
Jul 28, 2022

Conversation

Torgen
Copy link
Contributor

@Torgen Torgen commented Aug 14, 2021

By moving the whitespace from between the handlebars to inside them, six newlines are eliminated from each instantiation of Template.dynamic.. This is important for cases where you need to have no whitespace between the dynamic template content and the surrounding tags.

By moving the whitespace from between the handlebars to inside them, six newlines are eliminated from each instantiation of Template.dynamic.. This is important for cases where you need to have no whitespace between the dynamic template content and the surrounding tags.
@CLAassistant
Copy link

CLAassistant commented Aug 14, 2021

CLA assistant check
All committers have signed the CLA.

@StorytellerCZ
Copy link
Collaborator

@Torgen can you provide an example between the current approach and your fix? Wouldn't minification take care of that?

@Torgen
Copy link
Contributor Author

Torgen commented Aug 19, 2021

https://github.com/Torgen/codex-blackboard/blob/gravatar-mentions/text_chunk.html
I essentially duplicated Template.dynamic with the whitespace removed to get the behavior I want.
Think of something like Slack or Twitter, where there's a plain-text way of @-mentioning someone or adding a hashtag, but you potentially want that rendered with a reactive component; often those apis include both a plaintext version and a chunked version, or have other metadata that marks the index ranges for special handling. For example, if you @-mention someone, maybe you want to show their avatar (which they're allowed to change) and something to indicate whether they're online. If there's a punctuation mark after the @-mention, it should stay attached, but the body of Template.dynamic having whitespace it it makes the browser think you want to put space between them.
I could always use Blaze.toHTML on my chunks and insert the entire message into the page with SafeString or {{{}}}, and if any of the components of the message has a reactive update, the entire thing will get re-rendered. I'm not sure if you want to encourage that.

@StorytellerCZ
Copy link
Collaborator

Alright, will include this in Blaze 2.6

@filipenevola
Copy link
Collaborator

@StorytellerCZ I believe this should be documented as a possible breaking change.

@StorytellerCZ StorytellerCZ added this to the Blaze 3.0 milestone Jan 1, 2022
@StorytellerCZ StorytellerCZ changed the base branch from master to release-3.0 April 15, 2022 13:48
@StorytellerCZ StorytellerCZ merged commit 41d3611 into meteor:release-3.0 Jul 28, 2022
StorytellerCZ added a commit that referenced this pull request Jul 28, 2022
@Torgen Torgen deleted the dynamic-no-whitespace branch October 21, 2022 03:53
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.

4 participants