diff options
author | Valerio Virgillito | 2012-07-17 11:29:09 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-17 11:29:09 -0700 |
commit | 58e86247524cc2d545bd6884f1b5c9fdba3b9164 (patch) | |
tree | 53305d354fce502ee39378babf47ace6c91ce2fd /imports/codemirror/mode/erlang/index.html | |
parent | 0f0cffd4df85e7adf5081fe66c768c70b2ead9b3 (diff) | |
parent | 4f737b24c19ddc02d20f9783b8b080fc6ef11142 (diff) | |
download | ninja-58e86247524cc2d545bd6884f1b5c9fdba3b9164.tar.gz |
Merge branch 'refs/heads/master' into v0.7.1
Diffstat (limited to 'imports/codemirror/mode/erlang/index.html')
-rw-r--r-- | imports/codemirror/mode/erlang/index.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/imports/codemirror/mode/erlang/index.html b/imports/codemirror/mode/erlang/index.html new file mode 100644 index 00000000..625491f2 --- /dev/null +++ b/imports/codemirror/mode/erlang/index.html | |||
@@ -0,0 +1,61 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror: Erlang mode</title> | ||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
6 | <script src="../../lib/codemirror.js"></script> | ||
7 | <script src="erlang.js"></script> | ||
8 | <link rel="stylesheet" href="../../theme/erlang-dark.css"> | ||
9 | <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> | ||
10 | <link rel="stylesheet" href="../../doc/docs.css"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <h1>CodeMirror: Erlang mode</h1> | ||
14 | |||
15 | <form><textarea id="code" name="code"> | ||
16 | %% -*- mode: erlang; erlang-indent-level: 2 -*- | ||
17 | %%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com> | ||
18 | |||
19 | %% @doc | ||
20 | %% Demonstrates how to print a record. | ||
21 | %% @end | ||
22 | |||
23 | -module('ex'). | ||
24 | -author('mats cronqvist'). | ||
25 | -export([demo/0, | ||
26 | rec_info/1]). | ||
27 | |||
28 | -record(demo,{a="One",b="Two",c="Three",d="Four"}). | ||
29 | |||
30 | rec_info(demo) -> record_info(fields,demo). | ||
31 | |||
32 | demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}). | ||
33 | |||
34 | expand_recs(M,List) when is_list(List) -> | ||
35 | [expand_recs(M,L)||L<-List]; | ||
36 | expand_recs(M,Tup) when is_tuple(Tup) -> | ||
37 | case tuple_size(Tup) of | ||
38 | L when L < 1 -> Tup; | ||
39 | L -> | ||
40 | try Fields = M:rec_info(element(1,Tup)), | ||
41 | L = length(Fields)+1, | ||
42 | lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup)))) | ||
43 | catch _:_ -> | ||
44 | list_to_tuple(expand_recs(M,tuple_to_list(Tup))) | ||
45 | end | ||
46 | end; | ||
47 | expand_recs(_,Term) -> | ||
48 | Term. | ||
49 | </textarea></form> | ||
50 | |||
51 | <script> | ||
52 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
53 | lineNumbers: true, | ||
54 | matchBrackets: true, | ||
55 | theme: "erlang-dark" | ||
56 | }); | ||
57 | </script> | ||
58 | |||
59 | <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p> | ||
60 | </body> | ||
61 | </html> | ||