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

Can't insert JSX files into Jade template #144

Closed
viniciusbo opened this issue Oct 6, 2015 · 6 comments
Closed

Can't insert JSX files into Jade template #144

viniciusbo opened this issue Oct 6, 2015 · 6 comments
Labels

Comments

@viniciusbo
Copy link

Supposing I have the files /path/to/my/js/file.js, /path/to/my/js/file.jsx, and the following jade template:

//- inject:js
//- endinject

//- inject:jsx
//- endinject

This is the output:

//- inject:js
script(src="/path/to/my/js/file.js")
//- endinject

//- inject:jsscript(src="/path/to/my/js/file.js")//- endinject

Instead of:

//- inject:js
script(src="/path/to/my/js/file.js")
//- endinject

//- inject:jsx
script(type="text/jsx", src="/path/to/my/js/file.jsx")
//- endinject

Have anybody been throught this? Am I missing something?

@joakimbeng
Copy link
Member

Aha, I think the bug is caused by the regex being too generic in this case. Because the regex generated for //- inject:js also matches //- inject:jsx.
This doesn't happen when injecting into html because then the starttag ends in --> so there's no ambiguity there.

@joakimbeng joakimbeng added the bug label Oct 8, 2015
@joakimbeng
Copy link
Member

A quickfix until it's solved is to set the starttag option to starttag: '//- inject:{{ext}}., note the trailing . and use //- inject:js. and //- inject:jsx. in your jade template instead.

@viniciusbo
Copy link
Author

Could not get that to work with this fix, .jsx files don't get injected.
Now //- inject:jsx comment is left untouched btw.

@viniciusbo
Copy link
Author

Hey @joakimbeng I've been trying to track the source of this bug, which seems to be in src/inject/index.js:257.

Technically, adding regex word boundary \b to the end of the first group would do the right match, as seen here: http://www.regexr.com/3c501. But for some reason all inject tests fail.

If you have any thoughts that could point to the right direction would be great. I will keep hunting.

joakimbeng added a commit that referenced this issue Mar 18, 2016
…should solve #144)

Breaking: using ES2015 syntax features available from NodeJS v4
@joakimbeng
Copy link
Member

@viniciusbo sorry for the delay, but this is now solved in v4.0.0!

@viniciusbo
Copy link
Author

Nice to know @joakimbeng, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants