Compose
Functional templating for Vala
Last updated
Was this helpful?
Functional templating for Vala
Last updated
Was this helpful?
Functional templating for Vala.
Using expressions for evaluating templates presents many advantages:
it's fast
it's quite elegant
lazy evaluation using callbacks with native environments
it's reusable since nodes can be isolated in functions
it provides minimal compile-time correctness
HTML5 elements support
Attributes are passed as an null-terminated array of key=value
entries, just like environment variables. There is no need to quote or escape what follows the =
sign.
Also, Compose will automatically escape data where it has to be.
Every HTML5 elements can be found within the Compose.HTML5
namespace like shown in the first code example.
To escape values, which is not done by default if HTML is expected, use the e
helper.
Note that all attributes are already escaped.
Support for other format will be included if the project happen to become successful.
Compose work like a sink, so it will consume data from various sources through a simple callback API. Lazy evaluation at it's finest!
Test some condition and render either the first or second callback result.
Consume a callback until it return null
, using another callback to perform evaluation.
To help keep track of the current index an array is used, a counter is passed as first argument.