A templating language that looks like Lisp and compiles to HTML
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

env.js 628B

12345678910111213141516171819202122232425262728293031
  1. module.exports = class Env {
  2. constructor(parent = null) {
  3. if (parent) {
  4. this.data = parent.data
  5. } else {
  6. this.data = {
  7. '+': (a, b) => a + b,
  8. '-': (a, b) => a - b,
  9. '*': (a, b) => a * b,
  10. '/': (a, b) => a / b,
  11. '=': (a, b) => a === b,
  12. '>': (a, b) => a > b,
  13. '<': (a, b) => a < b,
  14. '>=': (a, b) => a >= b,
  15. '<=': (a, b) => a <= b,
  16. }
  17. }
  18. }
  19. get(symbol) {
  20. if (this.data[symbol]) {
  21. return this.data[symbol]
  22. }
  23. throw `Symbol ${symbol} is not bound`
  24. }
  25. set(symbol, value) {
  26. this.data[symbol] = value
  27. }
  28. }