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

Top-level string doesn't interpolate #118

Closed
edemaine opened this issue Jan 5, 2023 · 4 comments
Closed

Top-level string doesn't interpolate #118

edemaine opened this issue Jan 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@edemaine
Copy link
Collaborator

edemaine commented Jan 5, 2023

"civet coffeeInterpolation"
"Hello #{name}!"

compiles to "Hello #{name}!" (incorrect)

"civet coffeeInterpolation"
console.log "Hello #{name}!"

compiles to console.log(`Hello ${name}`) (correct)

@edemaine edemaine added the bug Something isn't working label Jan 5, 2023
@STRd6
Copy link
Contributor

STRd6 commented Jan 5, 2023

I think it has to do with caching. Since the "civet coffeeInterpolation" prologue directive changes the behavior of strings if it is followed by a string it may be parsed and cached. I'd prefer to not add strings to the non-cached list since that could affect parsing performance throughout the whole file.

Fine tuning the directive prologue parsing to only check for simple strings may fix this.

@STRd6
Copy link
Contributor

STRd6 commented Jan 5, 2023

It may be an open question whether we should mangle top level directive prologues. In this case "Hello #{name}!" is parsed as a JS prologue in the spec and probably shouldn't be interpolated no matter what civet config options are specified.

@edemaine
Copy link
Collaborator Author

edemaine commented Jan 5, 2023

Oh, I forgot about JS prologues. This behavior makes sense then, I think.

It might make sense to just clear the cache after parsing the Civet directive, though I'm not sure whether this is ever an issue.

@edemaine edemaine closed this as completed Jan 5, 2023
@STRd6
Copy link
Contributor

STRd6 commented Jan 5, 2023

I probably need to add a comment in the parser since I forgot about it until reading the code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants