Skip to content
Alexander Savin edited this page Jan 25, 2015 · 4 revisions

Currently bnsf uses BEMHTML and BEMTREE for templating.

Why do you need both?

In short: API server(s) produces some data -> BEMTREE produces some BEMJSON -> BEMHTML produces HTML.

There is an extended version of BEMTREE in bnsf, you can use path and redirect global functions, get BEMContext method and route BEMContext property. Of course, "global" means "global in bemtree templates only". Also, js mode added for BEMTREE.

It's better to explain with example.

page-hello-world.bemtree:

block('page-3').content()(function () {
    // you can get some data from api server(s) with get method
    return this.get('some_api_route', function (output) {
        return [
            {
                block: 'link',
                url: path('page-1'), // you can get app path with path global function
                content: 'main page'
            },
            {
                block: 'code-presenter',
                content: output.body
            }
        ]
    }/* optional error handler function here */, function () {
        redirect(path('some-another-path'));
    });
});

code-presenter.bemhtml may looks like this:

block('code-presenter').tag()('pre');

Clone this wiki locally