Conversation
achambers
approved these changes
Jun 22, 2023
Contributor
achambers
left a comment
There was a problem hiding this comment.
Had a crack at reviewing this against the RFC and it looks good to me. Left 2 comments/questions there for consideration. But overall, LGTM
| import templateOnly from "@ember/component/template-only"; | ||
| import { setComponentTemplate } from "@ember/component"; | ||
| import { precompileTemplate } from "@ember/template-compilation"; | ||
| let hasBlock = 1; |
| import HelloWorld from 'somewhere'; | ||
| export default class { | ||
| static { | ||
| template('<HelloWorld @color={{red}} />', { component: this, scope: () => ({ HelloWorld }) }); |
Contributor
There was a problem hiding this comment.
Looking at the RFC to reconcile this implementation and it got me wondering, is there value in a test that shows using the instance arg that's passed in to the scope function, say, for accessing private fields?
This is the code that got me wondering this:
// in class member position, we can also put private fields in scope
class extends Component {
static {
template(
"<Section @title={{this.title}} @subhead={{this.#secret}} />",
{
component: this,
scope: (instance) => ({
Section,
"#secret": instance.#secret
}),
},
)
}
}
Merged
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Edited to add: the call signature in the RFC has changed, this PR needs updating to that new call signature.
This implements emberjs/rfcs#931, which defines a stable low-level representation for template tags.
When using
targetFormat: 'hbs'it acts as a polyfill for the ahead-of-time compiler as described in the RFC, using only stable public APIs. Assuming the RFC is approved and implemented, this implementation could change so it leavestemplate()alone, rather than replacing it withprecompileTemplateandsetComponentTemplate.When using
targetFormat: 'wire'it's not really a polyfill, since this package is the definitive implementation.There are skipped tests to cover cases that are important but will depend on glimmerjs/glimmer-vm#1421
targetFormat: 'wire'with explicit formtargetFormat: 'hbs'with explicit formtargetFormat: 'wire'with implicit formtargetFormat: 'hbs'with implicit form