<erl> out(A) -> {ssi, "TAB.inc", "%%",[{"bindings", "choosen"}]}. </erl>

## Bindings

Bindings are the opposite of Server Side Includes (SSI). SSI is used when entire pages are written largely in EHTML and snippets of HTML, or more typically javascript code is inserted into the EHTML code.

Bindings are used the other way around. Essentially entire pages are written in regular HTML but parts of the HTML needs to be dynamically generated.

The yaws callback out/1 can return

          {bindings, [{Key1, Value2}, {Key2, Value2} .....]}.

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:binding(Key)` or `yaws_api:binding_find(Key)` can be used to extract Value.

By default, text that looks like `%%Key%%` is left as is if Key is not included in the bindings list. To force Yaws to treat all undefined bindings as empty strings, so it strips out any text like `%%Key%%` when Key is not specified, include the special directive `strip_undefined` in the bindings list.

With the binding feature it is easier to write transparent yaws code making it easier to to work together with Web people knowing little or nothing about Erlang.

An example:

<verbatim> <erl> out(A) -> {bindings, [{"A", "foo"}, {"B", "baz"}]}. </erl>

%%A%%

%%A%% != %%B%%

An enormous amount of plain html source here.

<erl> out(A) -> Value = yaws_api:binding("A"), {ehtml, {ul, [], [{li, [], Value}, {li, [], "gazonk"}]}}. </erl> %%A%% = %%A%% (hit me)
</verbatim>

Which expands to:

<verbatim>

foo

foo != baz

An enormous amount of plain html source here.

- foo
- gazonk

foo = foo (hit me)
</verbatim>

And is rendered as:

foo

foo != baz

An enormous amount of plain html source here.

- foo
- gazonk

foo = foo (hit me)
<erl> out(A) -> {ssi, "END2",[],[]}. </erl>