2  Walkthrough 👣

Let us briefly explore the Std.lang transpiler.

2.1 Setup

(ns stdlang-book.walkthrough
  (:require [std.lang :as l]
            [scicloj.kindly.v4.kind :as kind]
            [scicloj.kindly.v4.api :as kindly]))
(l/script :js)
{:lang :js,
 :runtime :default,
 :bootstrap false,
 :context :lang/js,
 :module stdlang-book.walkthrough,
 :module/internal {stdlang-book.walkthrough -},
 :module/primary #{}}

2.2 Basic examples

(!.js (+ 1 2))
"1 + 2;"

2.3 Data visualization with Javascript

(kind/hiccup
 [:div
  [:script
   (!.js
    (do (var m (L.map document.currentScript.parentElement))
        (m.setView [-37.84 144.95]
                   11)
        (-> (L.tileLayer.provider "OpenStreetMap.Mapnik")
            (. (addTo m)))
        (-> [-37.9 144.8]
            L.marker
            (. (addTo m))
            (. (bindPopup "<i style='color:purple'>Have you been here?</i>"))
            (. (openPopup)))))]]
 {:html/deps [:leaflet]
  :style {:height "400px"}})
source: notebooks/stdlang_book/walkthrough.clj