Skip to content

Commit

Permalink
WIP: #435 Fix BEMHTML templates to work in development
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed Dec 23, 2013
1 parent 8a5486d commit 34f32ba
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 44 deletions.
8 changes: 4 additions & 4 deletions blocks-common/i-jquery/_version/i-jquery_version.bemhtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('i-jquery').def()(
applyCtx({
block('i-jquery').def()(function() {
return applyCtx({
block: 'b-page',
elem: 'js',
url: this.ctx.url || (this.ctx.protocol ? this.ctx.protocol + ':' : '') + '//yandex.st/jquery/' + this.mods.version + '/jquery.min.js'
})
)
});
});
59 changes: 31 additions & 28 deletions blocks-desktop/b-page/__css/b-page__css.bemhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,41 @@ block('b-page').elem('css')(

tag()('style'),

def().match(this.ctx.hasOwnProperty('ie')).match(!this.ctx._ieCommented)(function () {
var ie = this.ctx.ie;
if (ie === true) {
apply({
_mode:'',
ctx: [6, 7, 8, 9].map(function(v) {
return { elem: 'css', url: this.ctx.url + '.ie' + v + '.css', ie: 'IE ' + v } }, this)
});
} else {
var hideRule = !ie ?
['gt IE 9', '<!-->', '<!--'] :
ie === '!IE' ?
[ie, '<!-->', '<!--'] :
[ie, '', ''];
apply({
_mode: '',
'ctx._ieCommented': true,
ctx: [
'<!--[if ' + hideRule[0] + ']>',
hideRule[1],
this.ctx,
hideRule[2],
'<![endif]-->'
]
});
def()
.match(function() { return this.ctx.hasOwnProperty('ie'); })
.match(function() { return !this.ctx._ieCommented; })(function () {
var ie = this.ctx.ie;
if (ie === true) {
apply({
_mode:'',
ctx: [6, 7, 8, 9].map(function(v) {
return { elem: 'css', url: this.ctx.url + '.ie' + v + '.css', ie: 'IE ' + v } }, this)
});
} else {
var hideRule = !ie ?
['gt IE 9', '<!-->', '<!--'] :
ie === '!IE' ?
[ie, '<!-->', '<!--'] :
[ie, '', ''];
apply({
_mode: '',
'ctx._ieCommented': true,
ctx: [
'<!--[if ' + hideRule[0] + ']>',
hideRule[1],
this.ctx,
hideRule[2],
'<![endif]-->'
]
});
}
}
}),
),

match()(this.ctx.url)(
match()(function() { return this.ctx.url; })(

tag()('link'),
attrs()({ rel: 'stylesheet', href: this.ctx.url })
attrs()(function() { return { rel: 'stylesheet', href: this.ctx.url }; })

)

Expand Down
4 changes: 2 additions & 2 deletions blocks-desktop/b-page/__js/b-page__js.bemhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ block('b-page').elem('js')(

tag()('script'),

match(this.ctx.url)(
attrs()({ src: this.ctx.url })
match(function() { return this.ctx.url; })(
attrs()(function() { return { src: this.ctx.url }; })
)

)
16 changes: 10 additions & 6 deletions blocks-desktop/b-page/b-page.bemhtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
block('b-page')(

mode('doctype')(this.ctx.doctype || '<!DOCTYPE html>'),
mode('doctype')(function() {
return this.ctx.doctype || '<!DOCTYPE html>';
}),

mode('xUACompatible')(this.ctx['x-ua-compatible'] === false ? false : {
tag: 'meta',
attrs: { 'http-equiv': 'X-UA-Compatible', content: this.ctx['x-ua-compatible'] || 'IE=edge' }
mode('xUACompatible')(function() {
return this.ctx['x-ua-compatible'] === false ? false : {
tag: 'meta',
attrs: { 'http-equiv': 'X-UA-Compatible', content: this.ctx['x-ua-compatible'] || 'IE=edge' }
};
}),

def().match(function() { return !this.ctx._wrapped })(function () {
Expand Down Expand Up @@ -69,13 +73,13 @@ block('b-page')(
elem('meta')(
bem()(false),
tag()('meta'),
attrs()(this.ctx.attrs)
attrs()(function() { return this.ctx.attrs; })
),

elem('favicon')(
bem()(false),
tag()('link'),
attrs()({ rel: 'shortcut icon', href: this.ctx.url })
attrs()(function() { return { rel: 'shortcut icon', href: this.ctx.url }; })
)

)
8 changes: 4 additions & 4 deletions blocks-desktop/i-jquery/__core/i-jquery__core.bemhtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
block('i-jquery').elem('core').def()(
applyCtx({
block('i-jquery').elem('core').def()(function() {
return applyCtx({
block: 'b-page',
elem: 'js',
url: '//yandex.st/jquery/1.8.3/jquery.min.js'
})
)
});
});

0 comments on commit 34f32ba

Please sign in to comment.