UNPKG

2.82 kBPlain TextView Raw
1;; LispyScript example using nodejs, expressjs and twitter bootstrap
2;; LispyScript templates are written in LispyScript!
3;; Html5 templates support all html5 tags
4
5;; The express server
6
7(var express (require "express"))
8(var app (express))
9(app.listen 3000)
10(app.use (express.static (+ __dirname "/public")))
11
12;; Include html5 template support
13
14(include "html.ls")
15
16;; Base Page template common to all pages
17;; To which we pass arguments title, navBarLinks, bodyContent
18;; when we call the template
19
20(template basePage (pageTitle navBarLinks bodyContent)
21 (html {lang:"en"}
22 (head
23 (title pageTitle)
24 (link {href:'bootstrap/css/bootstrap.css', rel:'stylesheet'})
25 (style {type:'text/css'}
26 "body {
27 padding-top: 60px;
28 }")
29 (link {href:'bootstrap/css/bootstrap-responsive.css', rel:'stylesheet'})
30 (!-- 'Le HTML5 shim, for IE6-8 support of HTML5 elements')
31 "<!--[if lt IE 9]>
32 <script src='http://html5shim.googlecode.com/svn/trunk/html5.js'></script>
33 <![endif]-->")
34 (body
35 (div {class:"navbar navbar-fixed-top"}
36 (div {class:"navbar-inner"}
37 (div {class:"container"}
38 (a {class:"btn btn-navbar",
39 "data-toggle":"collapse",
40 "data-target":".nav-collapse"}
41 "<span class='icon-bar'></span>"
42 "<span class='icon-bar'></span>"
43 "<span class='icon-bar'></span>")
44 (a {class:"brand", href:"#"} "LispyScript!")
45 (div {class:"nav-collapse"}
46 navBarLinks)))) ;;navBarLinks added here
47 bodyContent ;;bodyContent added here
48 (script {src:"//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",type:"text/javascript"})
49 (script {type:"text/javascript",src:"bootstrap/js/bootstrap.js"}))))
50
51;; the navBarLinks template
52
53(template navBarLinks ()
54 (ul {class:'nav'}
55 (li {class:'active'} (a {href:'#'} "Home"))
56 (li (a {href:'/tryit'} "Try It"))
57 (li (a {href:'/docs'} "Docs"))))
58
59;; the bodyContent template
60
61(template bodyContent ()
62 (div {class:'container'}
63 (div {class:'page-header'}
64 (h1 "LispyScript")
65 (p "A javascript With Lispy Syntax And Macros!"))
66 (div {class:'row'}
67 (div {class:'span6'}
68 (h2 "Overview")
69 (p "An inherent problem with Javascript is that it has no macro support, like other Lisp like languages. That's because macros manipulate the syntax tree while compiling. And this is next to impossible in a language like Javascript."))
70 (div {class:'span6'}
71 (h2 "Installing")
72 (h4 "Install Using npm")
73 (pre "$ npm install -g lispyscript")))))
74
75;; Send It!
76
77(app.get "/"
78 (function (req res)
79 (res.send (basePage "LispyScript" (navBarLinks) (bodyContent)))))