-
Notifications
You must be signed in to change notification settings - Fork 267
/
ssi.yaws
83 lines (56 loc) · 2.35 KB
/
ssi.yaws
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
<erl>
box(Str) ->
{'div',[{class,"box"}],
{pre,[],Str}}.
tbox(T) ->
box(lists:flatten(io_lib:format("~p",[T]))).
ssi(File) ->
{'div',[{class,"box"}],
{pre,[],
{ssi, File,[],[]}}}.
out(A) ->
[{ssi, "HEAD", [],[]},
{ssi, "EXHEAD", [],[]},
{ehtml,
[{h1, [], "Server side includes (with variable expansion)"},
{p, [],
"This feature is useful when we are writing applications where "
"basically the entire page is dynamically generated but we also "
"want to include snippets of either html or, even more typically,"
" javascript which is almost static, but not quite."},
{p, [], "In particular the case with dynamically generated javascript "
"can get syntactically ugly. So instead of generating strings in "
"the erlang code for the javascripts and returning them as "
"{pre_html, Data} tuples, it is more beautiful to keep the "
"javascript functions in separate files and include them with "
"the {ssi ...} return value."},
{p, [], "The format of the ssi statement is:"},
{br},
box("{ssi, File, Delimiter, Bindings}"),
{p, [],"The ssi structure can occur in two radically different places"
" but with identical semantics. It can be a return value in the "
" out/1 function and it is a specially treated return value "
"in ehtml output, here is an example of an odd return value "
"from out/1"},
tbox([{ssi, "ssi_ex1", "%", [{"a", "gazzonk"}]},
{ehtml,
[
{h1, "a Header"},
{ssi, "ssi_ex1", "%", [{"a", "zippo"}]}]}]),
{p,[], "The file ssi_ex1 contains the following text:"},
ssi("ssi_ex1"),
{p, [], "And the following ehtml output:"},
tbox({ehtml,[{ssi, "ssi_ex1", "%", [{"a", "Godzilla"}]}]}),
{p,[], "Generates the following output"},
{'div',[{class,"box"}],
{pre,[],
{ssi, "ssi_ex1", "%", [{"a", "Godzilla"}]}}},
{p, [], "And so does the following out/1 function"},
box("out(A) -> [{ssi, \"ssi_ex1\", \"%\", [{\"a\", \"Godzilla\"}]}]."),
{p,[], "So this is the way to do when we want to embed dynamic content"
" deep inside an ehtml structure, but the content isn't representable"
" as ehtml. This is typically the case for dynamically generated "
" javascript as well as dynamically generated java applets."}
]}].
</erl>
</html>