Closed luisaph closed 8 years ago
Hey, there isn't currently a way to do this, but there totally should be!
How soon do you need the feature?
I would use for a project that's due in two weeks, but it's not a critical thing :)
Ok, I've implemented basic support for it! It's documented here:
https://toolness.github.io/p5.js-widget/#src
So your example snippet should work now.
I also tried to handle error conditions gracefully, so if the file couldn't be retrieved, you'll see something like this:
Another weird situation I've seen beginners run into happens when they've accidentally specified both a src
attribute and an inline script, e.g.:
<script type="text/p5" src="static/my-example.js">
function setup() {
// Do stuff here...
}
</script>
With normal script tags, browsers will use either the src
attribute or the inline script (I forget which), which often leaves the user confused when they edit the other one and don't see any changes. So instead, p5.js-widget treats this kind of situation as an error and displays this:
Anyhow, let me know if this works okay for you! Thanks for filing the issue.
Atul, this is great, thank you! I will let you know how it goes.
I would like to load code from an external file, like this:
Curious: is this feature supported?
When I try the above, instead of my sketch I see what seems to be a default one:
Thanks!