bem / bem-templates-converter Goto Github PK
View Code? Open in Web Editor NEWThis project forked from vkz/bemhtml-syntax
BEM Templates Converter: BEMHTML to BEMHML.js, BEMHTML to BH
This project forked from vkz/bemhtml-syntax
BEM Templates Converter: BEMHTML to BEMHML.js, BEMHTML to BH
Input file block
with BEMHTML:
block block, default: null
Run [email protected]
:
$ bemhtml-syntax -i block
Actual:
block('block').def()(null);
Expected:
block('block').def()('');
block('misspell').elem('link').def()(function() {
return applyCtx(this.extend(this.ctx, {
block: 'link',
elem: ''
}));
});
to
block('misspell').elem('link').def()(function() {
return applyCtx(this.extend(this.ctx, {
block: 'link',
elem: undefined
}));
});
Input file i-log
with BEMHTML:
logNodeAttrValue: JSON.stringify(this.ctx.logNode)
default {
this.ctx.logNode: { /* ... */ }
}
Run [email protected]
:
$ bemhtml-syntax -i i-log.bemhtml
Actual:
mode('logNodeAttrValue')(function() {
return JSON.stringify(this.ctx.logNode);
});
def()(
match(function() {
return this.ctx.logNode;
})(function() { /* ... */ })
);
Expected:
block('*')(
mode('logNodeAttrValue')(function() {
return JSON.stringify(this.ctx.logNode);
}),
def()(
match(function() {
return this.ctx.logNode;
})(function() { /* ... */ })
)
);
IN: block event, (this.mods && this.mods.type == 'sport')
OUT: block('event').match((this.mods && this.mods.type == 'sport'))
MUST BE: block('event').match(function() { return this.mods && this.mods.type == 'sport'; })
Our copy of vkz#12
Guess it could be very useful for migration to bem-xjst-next.
Related bem/bem-xjst#121
Input file suggest-item_type_nav
with BEMHTML:
block suggest-item, mod type nav {
default: {
var url = this.ctx.data[4];
applyNext({_url: (url.match(/^\w[\w-]*:\/\//g) ? '' : 'http://') + url});
}
}
Run [email protected]
:
$ bemhtml-syntax -i suggest-item_type_nav
Actual:
block('suggest-item').mod('type', 'nav')(
def()(function() {
var url = this.ctx.data[4];
return applyNext({
_url: (url.match('^\w[\w-]*:\/\/' // regexp turned to string
g) ? '' : 'http://') + url
});
}))
Expected:
block('suggest-item').mod('type', 'nav')(
def()(function() {
var url = this.ctx.data[4];
return applyNext({
_url: (url.match(/^\w[\w-]*:\/\//g) ? '' : 'http://') + url
});
}))
Autoconvert:
block('feedback').def()(function() {
return applyCtx({ block: 'feedback', elem: 'wrapper' });
});
to
block('feedback').replace()(function() {
return { block: 'feedback', elem: 'wrapper' };
});
Input file block
with BEMHTML:
block block, default {
!this.ctx._guard: {
apply(
this.ctx._guard = true
);
}
}
Run [email protected]
:
$ bemhtml-syntax -i block
Actual:
block('block').match(function () {
return !this.ctx._guard;
}).def()(function () {
return apply({
'ctx._guard': true
});
});
Expected:
block('block').match(function () {
return !this.ctx._guard;
}).def()(function () {
return applyNext({
'ctx._guard': true
});
});
block('a')(
elem('link').def()(function() {
applyNext();
})
);
block('a')(
elem('link').def()(function() {
return applyNext();
})
);
Input file block
with BEMHTML:
block block, default: {
applyNext(
this.ctx = {
block: 'other-block'
}
);
}
Run [email protected]
:
$ bemhtml-syntax -i block.bemhtml
Actual:
block('block').def()(function () {
return applyNext({
ctx: {
block: 'other-block'
}
});
});
Expected:
block('block').def()(function () {
return applyCtx({
block: 'other-block'
});
});
Input file block
with BEMHTML:
block block, default: {
applyNext(
_mode: '',
this.ctx = {
block: 'other-block'
}
);
}
Run [email protected]
:
$ bemhtml-syntax -i block.bemhtml
Actual:
block('block').def()(function () {
return applyNext({
_mode: '',
ctx: {
block: 'other-block'
}
});
});
Expected:
block('block').def().once()(function () {
return applyNext({
ctx: {
block: 'other-block'
}
});
});
Input file header
with BEMHTML:
block header {
default, ~['logo', 'search', 'nav'].indexOf(this.elem): {
/* ... */
}
}
Run [email protected]
:
$ bemhtml-syntax -i header.bemhtml
Actual:
block('header').def().match(function() {
return ~['logo', 'search', 'nav'].indexOf(this.elem);
})(function() {
/* ... */
});
Expected:
block('header').elem('*').match(function() {
return ~['logo', 'search', 'nav'].indexOf(this.elem);
}).def()(function() {
/* ... */
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.