-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
implementing rfc931 #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
__tests__/tests.ts
Outdated
import templateOnly from "@ember/component/template-only"; | ||
import { setComponentTemplate } from "@ember/component"; | ||
import { precompileTemplate } from "@ember/template-compilation"; | ||
let hasBlock = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ef4 Pretty sure this shouldn't here. ✂️
import HelloWorld from 'somewhere'; | ||
export default class { | ||
static { | ||
template('<HelloWorld @color={{red}} />', { component: this, scope: () => ({ HelloWorld }) }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
}),
},
)
}
}
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 withprecompileTemplate
andsetComponentTemplate
.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