erlydtl/erlydtl — pull request #130 by seriyps (2014-02-14 02:01:33+00:00)
Title: Runtime blocktrans (see #88)

Runtime `{% blocktrans %}` translation with runtime variable interpolation.

See #88 for initial discussion.

See tests for example usage.

Template
```erlang
erlydtl:compile(<<"111{%blocktrans with b=v.vv%}222{{ a }}333{{ b }}444{%endblocktrans%}555">>,
t, [debug_info, {out_dir, "/tmp"}, force_recompile]).
```
with no `blocktrans_fun` compile-time option will generate code like

```erlang
[<<49, 49, 49>>,
case _TranslationFun of
none -> % render using default scheme
[<<50, 50, 50>>,
erlydtl_filters:format_number(
erlydtl_runtime:fetch_value(a,
_Variables,
['...'])),
<<51, 51, 51>>,
erlydtl_filters:format_number(
erlydtl_runtime:find_value(
vv,
erlydtl_runtime:find_value(v, _Variables, ['...']),
['...'])),
<<52, 52, 52>>];
_ -> % translate and interpolate in runtime
erlydtl_runtime:translate_block(
"222{{ a }}333{{ b }}444",
_TranslationFun,
[{"a", % orddict of interpolation values
erlydtl_runtime:find_value(a, _Variables, ['...'])},
{"b",
erlydtl_runtime:find_value(
vv,
erlydtl_runtime:find_value(v, _Variables, ['...']),
['...'])}])
end,
<<53, 53, 53>>].
```

When `blocktrans_fun` is passed at compile-time, everything will be like before this changes.

No tests broken, docs improeved.