Skip to content

Instantly share code, notes, and snippets.

@maxpoletaev
Created March 2, 2014 21:26
Show Gist options
  • Save maxpoletaev/9314208 to your computer and use it in GitHub Desktop.
Save maxpoletaev/9314208 to your computer and use it in GitHub Desktop.
module.exports = function(bh) {
/**
* @block b-page
*/
bh.match('b-page', function(ctx) {
ctx.tag('body');
var html = {
tag: 'html',
content: [
{
tag: 'head',
content: ctx.param('head')
},
ctx.json()
]
};
return ['<!DOCTYPE html>' , html];
});
/**
* @block b-page
* @elem meta
*/
bh.match('b-page__meta', function(ctx) {
ctx.bem(false);
ctx.tag('meta');
});
/**
* @block b-page
* @elem title
*/
bh.match('b-page__title', function(ctx) {
ctx.bem(false);
ctx.tag('title');
});
/**
* @block b-page
* @elem css
*/
bh.match('b-page__css', function(ctx) {
ctx.bem(false);
ctx.tag('link');
var attrs = {
rel: 'stylesheet',
type: 'text/css'
};
if (ctx.param('url')) {
attrs.href = ctx.param('url');
}
ctx.attrs(attrs);
});
/**
* @block b-page
* @elem js
*/
bh.match('b-page__js', function(ctx) {
ctx.bem(false);
ctx.tag('script');
var attrs = {
type: 'text/javascript'
};
if (ctx.param('url')) {
attrs.src = ctx.param('url');
}
ctx.attrs(attrs);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment