Skip to content

Instantly share code, notes, and snippets.

@jacius
Last active December 12, 2015 08:59
Show Gist options
  • Save jacius/4748506 to your computer and use it in GitHub Desktop.
Save jacius/4748506 to your computer and use it in GitHub Desktop.
Using Chicken Scheme to generate HTML and JS
(require-library html-tags spock)
(import html-tags spock)
(display
(<html>
(<head>
(<spock-header>)
(<script> type: "text/javascript" src: "hello.js"))
(<body>)))
(define-native alert)
(alert "Hello, Vulcan.")
generated = hello.html hello.js spock-runtime-min.js
all: $(generated)
clean:
rm $(generated)
%.html: %.html.scm
csi -s $< > $@
%.js: %.js.scm
chicken-spock $< > $@
spock-runtime-%.js:
cp `chicken-spock -library-path`/$@ $@
@jacius
Copy link
Author

jacius commented Feb 10, 2013

Barebones example of using Chicken Scheme to generate HTML and JS, using the html-tags and spock eggs.

You will need:

  • Chicken Scheme
  • html-tags: chicken-install html-tags
  • spock: chicken-install spock
  • Make

Run make to generate the HTML and JS files, then open "hello.html" in a web browser.

Of course, you would realistically never use spock for something this simple. spock adds significant overhead, both in terms of downloads (spock-runtime-min.js file is almost 80K) and runtime speed / memory use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment