Answer the question
In order to leave comments, you need to log in
Alternative to html template from Bem?
Hello. Please tell me html template engines are very similar in their logic to bem tools, that is, in which you can create blocks on the page through json and, accordingly, so that this code is converted into an html page.
Answer the question
In order to leave comments, you need to log in
It's not generally accepted practice to generate HTML this way. Look at other solutions: Jade
preprocessors
, Haml
Template engines:
habrahabr.ru/post/219873
Anyone, more specifically in your case with JSON support, such as NANO , although roughly speaking closer to BH/BEMHTML , can be called json2html , an example of using json2html with CSS from bem-components:
var data = [
{
'text': 'BEM — BEM Easy Makeup',
'url': 'https://ru.bem.info/',
},
];
var template = {
tag: 'a',
class: 'button button_theme_islands button_size_xl',
href: '${url}',
children: [
{
tag: 'span',
class: 'icon icon_social_twitter',
},
{
tag: 'span',
class: 'button__text',
html: '${text}',
},
]
};
document.body.innerHTML = json2html.transform( data, template );
lavezzi1 , Jade / pug you won't find anything better. It already went through a month ago. Now I don’t understand how I lived without it for so many years :))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question