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

Simpler codegen #673

Merged
merged 12 commits into from
Jun 26, 2017
Merged

Simpler codegen #673

merged 12 commits into from
Jun 26, 2017

Conversation

Rich-Harris
Copy link
Member

This stops well short of the idea described in #652 (which I started investigating, but concluded it would probably add more complexity and indirection than it removes), but I think it goes a long way towards making the code-that-generates-the-code more readable.

// before
this.builders.unmount.addLine(
  `${this.generator.helper('detachNode')}( ${name} );`
);

// after
this.builders.unmount.addLine(
  `@detachNode( ${name} );`
);

Essentially @foo means 'alias foo, and register it as a helper if there's a helper called foo'. Similarly, for block-level aliases, as opposed to component-level, we can use #foo.

@Conduitry
Copy link
Member

Conduitry commented Jun 25, 2017

It looks like this has problems if the original component has things in it that look like these special identifiers. Compiling just the string @foo results in text = createText( "\\foo" );

Compiling {{'@foo'}} results in text = createText( text_value = '@foo' ); which seems fine.

Compiling #foo results in text = createText( "\#foo" ); which isn't ideal but technically works.

@Rich-Harris
Copy link
Member Author

Good catch! Should be fixed now

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.

2 participants