-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documented jockes new bindings feature
git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@582 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
- Loading branch information
Claes Wikstrom
committed
Jan 27, 2004
1 parent
a9a9971
commit 379666b
Showing
7 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<erl> | ||
out(A) -> | ||
[{ssi, "HEAD", [],[]}, | ||
{ssi, "EXHEAD", [],[]}]. | ||
</erl> | ||
|
||
|
||
<p> | ||
Bindings is the opposite of <a href="ssi.yaws"> SSI, Server Side Includes</a>, | ||
SSI is primarily used when basicaly the entire pages are written in EHTML and | ||
snippets of HTML, or more typical, javascript code is inserted into the EHTML | ||
code. | ||
|
||
<p> Bindings are used the other way around, basically the entire | ||
pages are written in regular HTML but parts of the HTML needs to be | ||
dynamically generated. | ||
|
||
<p>The yaws callback out/1 can return | ||
|
||
<div class="box"> | ||
<pre> | ||
{bindings, [{Key1, Value2}, {Key2, Value2} .....]}. | ||
</pre> | ||
</div> | ||
|
||
|
||
<p>All bindings can then be used in the rest of yaws code (in HTML source and | ||
within erl tags). In HTML source %%Key%% is expanded to Value and | ||
within erl tags yaws_api:get_binding(Key) can be used to extract Value. | ||
|
||
<p>With the binding feature it is easier to write transparant yaws code making | ||
it easier to to work together with Web people knowing little or | ||
nothing about Erlang. | ||
|
||
An example: | ||
|
||
|
||
<div class="box"> | ||
<pre> | ||
|
||
<erl> | ||
out(A) -> {bindings, [{"A", "foo"}, {"B", "baz"}]}. | ||
</erl> | ||
|
||
<html> | ||
<body> | ||
<p>%%A%%</p> | ||
<p><font size="4">%%A%% != %%B%%</font></p> | ||
<p>An enormous amount of plain html source here.</p> | ||
|
||
<erl> | ||
out(A) -> | ||
Value = yaws_api:binding("A"), | ||
{ehtml, {ul, [], | ||
[{li, [], | ||
Value}, | ||
{li, [], | ||
"gazonk"}]}}. | ||
</erl> | ||
|
||
%%A%% = %%A%% (hit me) | ||
</body> | ||
</html> | ||
</pre> | ||
</div> | ||
|
||
|
||
<p> | ||
Which expands to: | ||
|
||
<div class="box"> | ||
<pre> | ||
|
||
|
||
|
||
<html> | ||
<body> | ||
<p>foo</p> | ||
<p><font size="4">foo != baz</font></p> | ||
<p>An enormous amount of plain html source here.</p> | ||
|
||
<ul> | ||
<li>foo</li> | ||
<li>gazonk</li></ul> | ||
|
||
foo = foo (hit me) | ||
|
||
|
||
|
||
</pre> | ||
</div> | ||
|
||
|
||
And is rendered as: | ||
<div class="box"> | ||
<p>foo</p> | ||
<p><font size="4">foo != baz</font></p> | ||
<p>An enormous amount of plain html source here.</p> | ||
|
||
<ul> | ||
<li>foo</li> | ||
<li>gazonk</li></ul> | ||
|
||
foo = foo (hit me) | ||
</div> | ||
|
||
|
||
|
||
|
||
|
||
</html> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters