Skip to content

NickCellino/clj-browser-eval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-browser-eval

This is a thing that lets you turn any HTML input field into a Clojure interpreter.

clj-browser-eval.gif

CodePen: https://codepen.io/nichelodean/pen/zYWEgeW

quick start

In your html:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js"></script>

<div clj-interpreter>
  <textarea clj-code></textarea>
  <button clj-eval>Evaluate</button>
  <pre clj-result></pre>
</div>

clj-interpreter marks the container div for an interpreter

clj-code marks the text input that you want to use as the input for the interpreter

clj-eval designates the button (or any clickable thing) that you want to use to trigger evaluation

clj-result (optional - results will be window.alert'ed if this is not provided) designates where the result should go

multiple interpreters on one page

You can do as many of these on a page as you like!

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js"></script>

<div clj-interpreter>
  <textarea clj-code></textarea>
  <button clj-eval>Evaluate</button>
  <pre clj-result></pre>
</div>

<div clj-interpreter>
  <textarea clj-code></textarea>
  <button clj-eval>Evaluate</button>
  <pre clj-result></pre>
</div>

<div clj-interpreter>
  <textarea clj-code></textarea>
  <button clj-eval>Evaluate</button>
  <pre clj-result></pre>
</div>

installing with npm

npm install clj-browser-eval

some considerations

I have no idea what I'm doing and you should not use this for anything real.

credits

Made possible by scittle!

About

turn any HTML input field into a Clojure interpreter

Resources

License

Stars

Watchers

Forks

Packages

No packages published