5 <title>CodeMirror: Erlang mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <script src="../../lib/codemirror.js"></script>
8 <script src="../../addon/edit/matchbrackets.js"></script>
9 <script src="erlang.js"></script>
10 <link rel="stylesheet" href="../../theme/erlang-dark.css">
11 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12 <link rel="stylesheet" href="../../doc/docs.css">
15 <h1>CodeMirror: Erlang mode</h1>
17 <form><textarea id="code" name="code">
18 %% -*- mode: erlang; erlang-indent-level: 2 -*-
19 %%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com>
22 %% Demonstrates how to print a record.
26 -author('mats cronqvist').
30 -record(demo,{a="One",b="Two",c="Three",d="Four"}).
32 rec_info(demo) -> record_info(fields,demo).
34 demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
36 expand_recs(M,List) when is_list(List) ->
37 [expand_recs(M,L)||L<-List];
38 expand_recs(M,Tup) when is_tuple(Tup) ->
39 case tuple_size(Tup) of
42 try Fields = M:rec_info(element(1,Tup)),
44 lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
46 list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
49 expand_recs(_,Term) ->
54 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
57 extraKeys: {"Tab": "indentAuto"},
62 <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>