Skip to content

Instantly share code, notes, and snippets.

@narqo
Created May 29, 2013 16:19
Show Gist options
  • Save narqo/5671575 to your computer and use it in GitHub Desktop.
Save narqo/5671575 to your computer and use it in GitHub Desktop.
How to redefine something in BEMHTML?
// PRJ/[...]/b-page.bemhtml
block b-page {
default: {
var ctx = this.ctx,
dtype = apply(this._mode = 'doctype'),
buf = [
dtype,
{
elem: 'root',
content: [
{
elem: 'head',
content: [
{
tag: 'meta',
attrs: { charset: 'utf-8' }
},
{
tag: 'meta',
attrs: { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' } // Хочу `edge` и все!
},
{
tag: 'title',
content: ctx.title
},
ctx.favicon ? {
elem: 'favicon',
url: ctx.favicon
} : '',
ctx.meta,
{
block: 'i-ua'
},
ctx.head
]
},
ctx
]
}
];
applCtxy(buf);
}
}
block b-page, elem head {
content: {
// TODO: пример переопределения только `__head`
}
}
block b-page, elem head {
this.ctx && this.ctx.tag === 'meta' && this.ctx.attrs && this.ctx.attrs['http-equiv']: {
applyCtx({
tag : this.ctx.tag,
attrs : {
'http-equiv' : 'X-UA-Compatible',
content : 'IE=edge'
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment