forked from sweet-js/sweet-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
229 lines (179 loc) · 5.07 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!doctype html>
<html>
<head>
<title>sweet.js</title>
<link href='http://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="editor/theme/sweetprism.css">
<link href='prism.css' rel='stylesheet' />
<style>
html {
border-top: solid 1px red;
}
body {
margin: 0;
padding: 0;
/*border-top: 2px solid #676767;*/
}
#body {
width: 600px;
margin: 0 auto;
position: relative;
top: 75px;
}
#logo {
float: left;
width: 275px;
}
#nav {
margin-top: 30px;
float: right;
}
#nav ul {
list-style-type: none;
}
#content {
float: left;
width: 650px;
padding-bottom:50px;
}
h1,h2,h3 {
font-family: Helvetica Neue;
font-weight: 100;
color: #222;
position: relative;
text-transform: uppercase;
color: #444;
font-family: 'Lato', Helvetica Neue, Helvetica, Arial, sans-serif;
font-weight: 100;
border-bottom: solid 1px #eee;
}
h1 {
font-size: 300%;
}
h2 {
font-size: 180%;
}
h3 {
font-size: 150%;
}
p, li {
font-family: 'Source Sans Pro', sans-serif;
/*font-weight: 400;*/
font-size: large;
}
p code {
font-size: 14px;
}
li code {
font-size: 14px;
}
#content p#slogan {
margin-top: 1em;
}
#content p#placeholder {
margin-top: 8em;
}
a.mozilla {
position: relative;
float: left;
display: block;
height: 49px;
width: 118px;
background: url(mozilla-tab.png) 100% 0 no-repeat;
text-indent: -200px;
overflow: hidden;
margin-left: 20px;
}
.editor { display : none }
/* to display output of macro expansions */
.console {
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
padding: 1em;
margin-top:1em;
white-space: pre;
background: #f5f2f0;
resize: vertical;
max-height: 700px;
overflow: auto;
font-family: Consolas, Monaco, "Andale Mono", monospace;
text-shadow:0 1px white;
display:none;
}
</style>
</head>
<body class="language-javascript">
<div id="header">
<a class="mozilla" href="http://www.mozilla.org/">visit <span>mozilla</span></a>
</div>
<a href="http://github.com/mozilla/sweet.js">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
</a>
<div id="body">
<div id="logo"><img src="sweetjs.png"></div>
<div id="nav">
<ul>
<li> <a href="doc/main/sweet.html">documentation</a> </li>
<li> <a href="browser/editor.html">online editor</a> </li>
<li> <a href="https://github.com/mozilla/sweet.js">github project</a></li>
</ul>
</div>
<div id="content">
<h1 id='sweeten_your_javascript'>Sweeten Your JavaScript</h1>
<p>Sweet.js brings the hygienic macros of languages like Scheme and Rust to JavaScript. Macros allow you to sweeten the syntax of JavaScript and craft the language you’ve always wanted.</p>
<p>Do you want to use class syntax but don’t want to wait for ES6? Add them yourself with just a couple lines of code!</p>
<pre><code>// Define the class macro here...
macro class {
rule {
$className {
constructor $cparams $cbody
$($mname $mparams $mbody) ...
}
} => {
function $className $cparams $cbody
$($className.prototype.$mname
= function $mname $mparams $mbody; ) ...
}
}
// An now classes are in JavaScript!
class Person {
constructor(name) {
this.name = name;
}
say(msg) {
console.log(this.name + " says: " + msg);
}
}
var bob = new Person("Bob");
bob.say("Macros are sweet!");</code></pre>
<p>To get a better sense of what macros can do, check out some <a href='https://github.com/mozilla/sweet.js/wiki/Example-macros'>example macros</a> or play around with macros in the online <a href='browser/editor.html'>editor</a>.</p>
<h1 id='getting_sweetjs'>Getting sweet.js</h1>
<p>Install the sweet.js compiler via npm:</p>
<pre><code>$ npm install -g sweet.js</code></pre>
<p>Use the <code>sjs</code> binary to compile your sweet code:</p>
<pre><code>$ sjs -o output.js my_sweet_code.js</code></pre>
<h2>Next Steps</h2>
<ul>
<li>Read the <a href="doc/main/sweet.html">documentation</a>.</li>
<li>Write macros in the online <a href='browser/editor.html'>editor</a>.</li>
<li>Report issues on <a href='https://github.com/mozilla/sweet.js/issues'>github</a>.</li>
<li>Ask for help at #sweet.js on irc.mozilla.org.</li>
<li>Join the <a href='https://groups.google.com/forum/#!forum/sweetjs'>mailing list</a>.</li>
</ul>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34844488-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="prism.js"></script>
</body>
</html>