-
Notifications
You must be signed in to change notification settings - Fork 190
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
validate if in-element has already been transformed #1159
Conversation
I was using it for some preprocessing, and then it broke at the end when glimmer was parsing the final template (only if it had in-element)
@patricklx thank you for changes! Could you fix fomatting using |
value.type === 'StringLiteral' && | ||
!value.value.startsWith('%cursor:') |
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.
Hmm, why would we expect guid
to be passed?
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.
this happens when I do glimmer preprocess -> print (at this stage its passing guid) -> preprocess printed result again fails.
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.
Hmm, this only happens when compiling not when parsing / printing. Maybe you are using an older version of glimmer-vm that did this during syntax parsing?
Can you describe the tooling that you are using (and the versions) that hit the issue?
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.
I've created #1164 which shows that we can do the following:
import { preprocess, print } from '@glimmer/syntax';
let template = '{{#in-element this.someElement}}Content here{{/in-element}}';
let ast = preprocess(template);
let reprintedOutput = print(ast);
assert.equal(reprintedOutput, template);
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.
ah, that could be. was trying out custom hbs preprocessing (not ast plugin).
So, i was using the glimmer package directly (v0.42.2).
But when the template was processed by ember it failed to process it.
"ember-source": "^3.21.1"
actually with embroider:
"@embroider/core": "^0.23.0"
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.
this happens when I do glimmer preprocess -> print (at this stage its passing guid) -> preprocess printed result again fails.
Maybe you are using an older version of glimmer-vm that did this during syntax parsing?
Specifically, I think you are probably using a version of glimmer-vm prior to this PR: #1086. That landed in @glimmer/syntax@0.52.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.
just tested again to be sure, but this does still fail:
const glimmer = require('@glimmer/syntax');
const result = glimmer.preprocess(`<div>{{#in-element destinationElement~}}
{{yield yieldHash}}
{{~/in-element}}</div>`);
const printed = glimmer.print(result);
console.log(printed);
glimmer.preprocess(printed);
console.log:
<div>{{#in-element destinationElement guid="%cursor:0%" insertBefore=undefined~}}{{yield yieldHash}}{{~/in-element}}</div>
error:
SyntaxError: Cannot pass
guid from user space
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.
ah, updated to latest version works!
I was using it for some preprocessing, and then it broke at the end when glimmer was parsing the final template (only if it had in-element)