Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 127 lines (90 sloc) 2.272 kb
379666b @klacke documented jockes new bindings feature
authored
1 <erl>
2 out(A) ->
20ece13 @klacke more css hackery
authored
3 {ssi, "TAB.inc", "%%",[{"bindings", "choosen"}]}.
379666b @klacke documented jockes new bindings feature
authored
4 </erl>
5
6
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
7 <div id="entry">
9c5b959 @klacke ""
authored
8 <h2> Bindings </h2>
e35a591 @klacke more w3c compliance
authored
9 <p>
7811247 @vinoski whitespace cleanup
vinoski authored
10 Bindings are the opposite of
e35a591 @klacke more w3c compliance
authored
11 <a href="ssi.yaws"> Server Side Includes (SSI)</a>.
12 SSI is used when entire pages are written largely in EHTML and
7811247 @vinoski whitespace cleanup
vinoski authored
13 snippets of HTML, or more typically javascript code is
14 inserted into the EHTML
e35a591 @klacke more w3c compliance
authored
15 code.
16 </p>
17
7811247 @vinoski whitespace cleanup
vinoski authored
18 <p> Bindings are used the other way around. Essentially entire
19 pages are written in regular HTML but parts of the HTML needs to be
e35a591 @klacke more w3c compliance
authored
20 dynamically generated.
21 </p>
7811247 @vinoski whitespace cleanup
vinoski authored
22 <p>The yaws callback out/1 can return
e35a591 @klacke more w3c compliance
authored
23 </p>
7811247 @vinoski whitespace cleanup
vinoski authored
24 <div class="box">
e35a591 @klacke more w3c compliance
authored
25 <pre>
7811247 @vinoski whitespace cleanup
vinoski authored
26 {bindings, [{Key1, Value2}, {Key2, Value2} .....]}.
e35a591 @klacke more w3c compliance
authored
27 </pre>
28 </div>
29
30
31 <p>All bindings can then be used in the rest of yaws code (in HTML source and
32 within erl tags). In HTML source %%Key%% is expanded to Value and
33 within erl tags yaws_api:get_binding(Key) can be used to extract Value.</p>
7811247 @vinoski whitespace cleanup
vinoski authored
34
e35a591 @klacke more w3c compliance
authored
35 <p>With the binding feature it is easier to write transparent yaws code making
36 it easier to to work together with Web people knowing little or
37 nothing about Erlang.</p>
38
39 <p>
40 An example:
41 </p>
42
379666b @klacke documented jockes new bindings feature
authored
43
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
44 <div class="box">
45 <verbatim>
46 <erl>
47 out(A) -> {bindings, [{"A", "foo"}, {"B", "baz"}]}.
48 </erl>
379666b @klacke documented jockes new bindings feature
authored
49
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
50 <html>
51 <body>
52 <p>%%A%%</p>
53 <p><font size="4">%%A%% != %%B%%</font></p>
54 <p>An enormous amount of plain html source here.</p>
379666b @klacke documented jockes new bindings feature
authored
55
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
56 <erl>
57 out(A) ->
379666b @klacke documented jockes new bindings feature
authored
58 Value = yaws_api:binding("A"),
59 {ehtml, {ul, [],
60 [{li, [],
61 Value},
62 {li, [],
63 "gazonk"}]}}.
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
64 </erl>
379666b @klacke documented jockes new bindings feature
authored
65
66 %%A%% = %%A%% (hit me)
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
67 </body>
68 </html>
69
70 </verbatim>
71 </div>
72
379666b @klacke documented jockes new bindings feature
authored
73
74
75 <p>
e35a591 @klacke more w3c compliance
authored
76 Which expands to:</p>
379666b @klacke documented jockes new bindings feature
authored
77
7811247 @vinoski whitespace cleanup
vinoski authored
78 <div class="box">
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
79 <verbatim>
379666b @klacke documented jockes new bindings feature
authored
80
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
81 <html>
82 <body>
83 <p>foo</p>
84 <p><font size="4">foo != baz</font></p>
85 <p>An enormous amount of plain html source here.</p>
379666b @klacke documented jockes new bindings feature
authored
86
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
87 <ul>
88 <li>foo</li>
89 <li>gazonk</li></ul>
379666b @klacke documented jockes new bindings feature
authored
90
91 foo = foo (hit me)
92
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
93 </body>
94 </html>
379666b @klacke documented jockes new bindings feature
authored
95
f875c2b @klacke added <verbatim> tag for .yaws files, It works as the pre (or the code) ...
authored
96 </verbatim>
e35a591 @klacke more w3c compliance
authored
97 </div>
379666b @klacke documented jockes new bindings feature
authored
98
99
e35a591 @klacke more w3c compliance
authored
100 <p> And is rendered as:</p>
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
101
7811247 @vinoski whitespace cleanup
vinoski authored
102 <div class="box">
e35a591 @klacke more w3c compliance
authored
103 <p>foo</p>
104 <p><font size="4">foo != baz</font></p>
105 <p>An enormous amount of plain html source here.</p>
379666b @klacke documented jockes new bindings feature
authored
106
e35a591 @klacke more w3c compliance
authored
107 <ul>
108 <li>foo</li>
109 <li>gazonk</li>
110 </ul>
379666b @klacke documented jockes new bindings feature
authored
111
e35a591 @klacke more w3c compliance
authored
112 foo = foo (hit me)
113 </div>
379666b @klacke documented jockes new bindings feature
authored
114
115
116
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
117 </div>
379666b @klacke documented jockes new bindings feature
authored
118
119
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug in...
authored
120 <erl>
121 out(A) -> {ssi, "END2",[],[]}.
122 </erl>
379666b @klacke documented jockes new bindings feature
authored
123
124
125
126
Something went wrong with that request. Please try again.