Skip to content

Added javascript render support by adding <script> tags to output if … #12

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

itsKaspar
Copy link

@itsKaspar itsKaspar commented Jun 22, 2022

added support for javascript rendering when the language "javascript" is selected. and added the opportunity to add a library through opts.library. sorry for sorta lazy code, trying a quick fix to get this working on my website before tommorrow, and thought I'd try and commit something for the first time to understand the process, refusal of commit is expected nppp

…the language "javascript" is selected. and added the opportunity to add a library through opts.library. sorry for sorta lazy code, trying a quick fix to get this working on my website before tommorrow, and thought I'd try and commit something for the first time to understand the process, refusal of commit is expected nppp
@nbriz
Copy link
Contributor

nbriz commented Oct 28, 2022

@itsKaspar ...sry for taking so long to reply to this!!!

i was going to suggest to that u update the library property from a String to an Array (so that folks could in theory pass multiple libraries)... but as i've been working on adding mult-file projects to netnet realized that there are actually other situations where we'd want the render to render alternative code besides adding a the <script> tags like u did (this works great for javascript, but what about working on a CSS file?) ...so i solved this problem a slightly different way... u can now do something like this:

const ne = new Netitor({
  ele: '#editor',
  render: '#output',
  language: 'javascript',
  code: `
  function setup() {
    createCanvas(400, 400);
  }

  function draw() {
    background(220);
    ellipse(50,50,80,80);
  }
  `
})

ne.update(`
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"><\/script>
  <script>{{code}}<\/script>
`)

think this would solve ur usecase right? as well as all sorts of other alternatives

@itsKaspar
Copy link
Author

itsKaspar commented Nov 4, 2022 via email

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