Last active
December 12, 2015 08:59
-
-
Save jacius/4748506 to your computer and use it in GitHub Desktop.
Using Chicken Scheme to generate HTML and JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require-library html-tags spock) | |
(import html-tags spock) | |
(display | |
(<html> | |
(<head> | |
(<spock-header>) | |
(<script> type: "text/javascript" src: "hello.js")) | |
(<body>))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-native alert) | |
(alert "Hello, Vulcan.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`/$@ $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Barebones example of using Chicken Scheme to generate HTML and JS, using the html-tags and spock eggs.
You will need:
chicken-install html-tags
chicken-install spock
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.