Do <script> tags work in template files? #45
Replies: 7 comments 14 replies
-
Honestly I can't figure how to make them work, I've checked other routers and they don't seem to be doing anything special for scripts neither |
Beta Was this translation helpful? Give feedback.
-
Okay, well the workarounds that worked for me is to have the script somewhere else, or to use inside attributes such as onclick or @click |
Beta Was this translation helpful? Give feedback.
-
@rehhouari is there a special way for importing a js module inside x-init? I am getting the following error:
This is my code => login.js
login.html
|
Beta Was this translation helpful? Give feedback.
-
Fixed with v 6.2.1 test it out and let me know if it works as intended |
Beta Was this translation helpful? Give feedback.
-
Hey @rehhouari thanks for the very nice work. I still haven't tested this, will do soon. Could you just explain how you implemented this? And what does this exactly mean: Will the script tags get excecuted multiple times (each time the route is matched)? Another cool feature I would like to suggest is the ability to define "Single File Components". I think you are almost there with this new "Embeded Scripts" feature. |
Beta Was this translation helpful? Give feedback.
-
I totally understand this.
I meant a component, which is nothing more than a template which is not tied to a route :) One idea how this could be implemented: So instead doing this: We would then change the content of x-data each time we place a component somewhere: And inside the component, Pinecone router would then add (or edit) the outer x-data attribute and attach the data passed.
To keep things simple, maybe components should not be allowed to have a script tag (for now). I'm just thinking loud, if you think this would make Pinecone router bloated, just ignore what I said :) |
Beta Was this translation helpful? Give feedback.
-
@rehhouari thanks a lot for the great work, I will be happy to test the next version. I have a feeling that we will end up with functionality similar to that of a bundler, but without having to deal with the complexity of using a bundler :) That's why I like Alpine, for its simplicity.. |
Beta Was this translation helpful? Give feedback.
-
Hi!
I tried to load a template file using x-template, and the code inside the <script> tag didn't work. Is it supposed to work?
Previously I've had to obfuscate <script> tags when including such code dynamically, like this:
document.write('<script type="text/javascript" src="..."><\/script>'); // from https://stackoverflow.com/a/17542683
Beta Was this translation helpful? Give feedback.
All reactions