Skip to content
/ jsblock Public

Runnable JavaScript code snippets in your browser. Powered by Ace Editor.

Notifications You must be signed in to change notification settings

tabeth/jsblock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jsblock

Executable JavaScript code snippets, in your browser. Powered by Ace Editor.

Usage

Say you want to allow users to test out some JavaScript that you've written, and you have some simple HTML that looks like this:

<html>
  <head>
   <script src="lib/jsblock.js"></script>
   <script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js"></script>
   <link type="text/css" rel="stylesheet" href="lib/jsblock.css">
  </head>

  <body>
    <pre id="code">
      var message = "Hello World";
      console.log(message);
    </pre>
  </body>
</html>

Readers won't be able to test anything out that way. You want to enrich this experience, but how? One way is through the creation of a jsblock.

How to create a jsblock:

  1. Include the JavaScript and CSS as well as Ace Editor in the web page.

  2. Convert the code into a code snippet into a jsblock with the easy API. One example might be:

new jsblock(document.getElementById('code'))
  1. Viola! Conversion of regular code to jsblock

Acknowledgements:

This was inspired by codeblock.js

About

Runnable JavaScript code snippets in your browser. Powered by Ace Editor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published