All Projects → bem → Bem Xjst

bem / Bem Xjst

Licence: other
bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server

Programming Languages

javascript
184084 projects - #8 most used programming language
declarative
70 projects

Projects that are alternatives of or similar to Bem Xjst

kirby-blade
Enable Laravel Blade Template Engine for Kirby 3
Stars: ✭ 20 (-82.61%)
Mutual labels:  template-engine, view
Diamond
Diamond is a full-stack web-framework written in The D Programming Language using vibe.d
Stars: ✭ 173 (+50.43%)
Mutual labels:  view, template-engine
Flexml
🚀基于Litho的Android高性能动态业务容器。
Stars: ✭ 225 (+95.65%)
Mutual labels:  view, template-engine
bh-php
PHP port of https://github.com/bem/bh. It's cool thing but better use this:
Stars: ✭ 33 (-71.3%)
Mutual labels:  template-engine, bem
Bladeone
The standalone version Blade Template Engine without Laravel in a single php file and without dependencies
Stars: ✭ 411 (+257.39%)
Mutual labels:  view, template-engine
Bars
Bars is a lightweight high performance HTML aware templating engine. Bars emits DOM rather than DOM-strings, this means the DOM state is preserved even if data updates happen.
Stars: ✭ 5 (-95.65%)
Mutual labels:  view, template-engine
Blade
🔪 A standalone version of Laravel's Blade templating engine for use outside of Laravel.
Stars: ✭ 542 (+371.3%)
Mutual labels:  view, template-engine
Egg View
Stars: ✭ 35 (-69.57%)
Mutual labels:  view, template-engine
Ticketview
🎫 A custom view for showing tickets
Stars: ✭ 101 (-12.17%)
Mutual labels:  view
Eps
A templating engine for PowerShell
Stars: ✭ 108 (-6.09%)
Mutual labels:  template-engine
Art Template
High performance JavaScript templating engine
Stars: ✭ 9,554 (+8207.83%)
Mutual labels:  template-engine
Mkloader
Beautiful and smooth custom loading views
Stars: ✭ 1,377 (+1097.39%)
Mutual labels:  view
Matchpy
A library for pattern matching on symbolic expressions in Python.
Stars: ✭ 109 (-5.22%)
Mutual labels:  pattern-matching
Tabbar
🔥空祖家的导航栏工具
Stars: ✭ 100 (-13.04%)
Mutual labels:  view
Pierotateview
android自定义View,带旋转动画的饼状图,区块点击事件,滑动到某一区块事件,可惯性旋转
Stars: ✭ 113 (-1.74%)
Mutual labels:  view
Geco
Simple code generator based on a console project, running on .Net core and using C# interpolated strings
Stars: ✭ 97 (-15.65%)
Mutual labels:  template-engine
Api2html
Using the data from your API, generate the HTML on the fly! Server-side rendering of the mustache templates
Stars: ✭ 97 (-15.65%)
Mutual labels:  template-engine
Dna.js
🧬 An uncomplicated user interface library for building data-driven semantic templates
Stars: ✭ 114 (-0.87%)
Mutual labels:  template-engine
Jsmart
jSmart is Smarty Javascript Template Engine, port of the PHP Smarty Template Engine
Stars: ✭ 111 (-3.48%)
Mutual labels:  template-engine
Pattern Matching Ts
⚡ Pattern Matching in Typescript
Stars: ✭ 107 (-6.96%)
Mutual labels:  pattern-matching

bem-xjst

Declarative template engine for the browser and server with regular JS syntax.

NPM version Build Status Dependency Status devDependency Status Coverage Status

Features

Templates are extensible: they can be redefined or extended

You can redefine or extend just a particular part of output not only by simple redefinition via new templates but also using ‘modes’. E.g. it may be a tag name or its content.

block('link')({ tag: 'span' });
// The template sets tag to `span` for all `link` blocks.
// And tag mode can be redefined if any condition passed.

block('link').match((node, ctx) => ctx.url)({ tag: 'a' });
// The template sets tag to `a` only if block `link` have `url` field.
// Otherwise tag will be ‘span’ as previous template says.

Pattern matching

Templates are written using pattern matching for the values and structure of input data

block('list')({ tag: 'ul' });
block('item')({ tag: 'li' });

We can apply these two declarative-style templates templates to data:

{
  block: 'list',
  content: [
    {
      block: 'item',
      content: {
          block: 'list',
          content: [
              { block: 'item', content: 'CSS' },
              { block: 'item', content: 'HTML' }
          ]
      }
    },
    {
      block: 'item',
      content: {
          block: 'list',
          content: { block: 'item', content: 'JS' }
      }
    }
  ] 
}

The result is:

<ul class="list">
    <li class="item">
        <ul class="list">
            <li class="item">CSS</li>
            <li class="item">HTML</li>
        </ul>
    </li>
    <li class="item">
        <ul class="list">
            <li class="item">JS</li>
        </ul>
    </li>
</ul>

As you can see templates are as simple as CSS.

Automatic recursive traversing upon input data

In the example above you may have noticed that bem-xjst automaticaly traverses input data by content fields. This behaviour is default feature of bem-xjst.

Default rendering

Built-in rendering behavior is used by default, even if the user didn’t add templates. Even without templates. For example from above it will be:

<div class="list">
    <div class="item">
        <div class="list">
            <div class="item">CSS</div>
            <div class="item">HTML</div>
        </div>
    </div>
    <div class="item">
        <div class="list">
            <div class="item">JS</div>
        </div>
    </div>
</div>

That is more than half of the work ;) You will add the salt (couple of templates for tags) and the HTML-soup is very tasty!

No DSL, only JavaScript

Written in JavaScript, so the entire JavaScript infrastructure is available for checking code quality and conforming to best practices.

Since templates is a regular JavaScript code you can use automatic syntax validator from your editor and tools like JSHint/ESLint.

Runs on a server and client

You can use bem-xjst in any browser as well as in any JavaScript VM. We support Node.JS v0.10 and higher.

Tell me more

See documentation:

  1. About
  2. Quick Start
  3. API: usage, methods, signatures and etc
  4. Input data format: BEMJSON
  5. Templates syntax
  6. Templates context
  7. Runtime: processes for selecting and applying templates

Try it

Online sandbox

Online demo allows you to share code snippets, change versions and etc. Happy templating!

Install npm package

To compile bem-xjst, you need Node.js v0.10 or later, and npm.

npm install bem-xjst

Copy-paste example from quick start or see simple example from repository. Then read documentation and start experimenting with bem-xjst.

Is bem-xjst used in production?

Yes. A lot of projects in Yandex and Alfa-Bank, also in opensource projects based on bem-core and bem-components.

Benchmarks

See readme.

Runtime linter

See readme.

Static linter and migration tool for templates

See readme.

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].