src/templates/tag_metadata.pug
//- bemto
//- Copyright(c) 2012 Roman Komarov <kizu@kizu.ru>
//- MIT Licensed
-
$bemto_tag_metadata = [
'hr' => [
'type' => 'self_closing'
],
'br' => [
'type' => 'self_closing'
],
'wbr' => [
'type' => 'self_closing'
],
'source' => [
'type' => 'self_closing'
],
'img' => [
'type' => 'self_closing'
],
'input' => [
'type' => 'self_closing'
],
'a' => [
'type' => 'inline'
],
'abbr' => [
'type' => 'inline'
],
'acronym' => [
'type' => 'inline'
],
'b' => [
'type' => 'inline'
],
'code' => [
'type' => 'inline'
],
'em' => [
'type' => 'inline'
],
'font' => [
'type' => 'inline'
],
'i' => [
'type' => 'inline'
],
'ins' => [
'type' => 'inline'
],
'kbd' => [
'type' => 'inline'
],
'map' => [
'type' => 'inline'
],
'pre' => [
'type' => 'inline'
],
'samp' => [
'type' => 'inline'
],
'small' => [
'type' => 'inline'
],
'span' => [
'type' => 'inline'
],
'strong' => [
'type' => 'inline'
],
'sub' => [
'type' => 'inline'
],
'sup' => [
'type' => 'inline'
],
'textarea' => [
'type' => 'inline'
],
'time' => [
'type' => 'inline'
],
'label' => [
'content_type' => 'inline'
],
'p' => [
'content_type' => 'inline'
],
'h1' => [
'content_type' => 'inline'
],
'h2' => [
'content_type' => 'inline'
],
'h3' => [
'content_type' => 'inline'
],
'h4' => [
'content_type' => 'inline'
],
'h5' => [
'content_type' => 'inline'
],
'h6' => [
'content_type' => 'inline'
],
'ul' => [
'content_type' => 'list'
],
'ol' => [
'content_type' => 'list'
],
'select' => [
'content_type' => 'optionlist'
],
'datalist' => [
'content_type' => 'optionlist'
]
];
$get_bemto_tag_type = function ($tagName) use (&$bemto_tag_metadata) {
if (isset($bemto_tag_metadata[$tagName]) && $bemto_tag_metadata[$tagName] && isset($bemto_tag_metadata[$tagName]['type']) && $bemto_tag_metadata[$tagName]['type']) {
return $bemto_tag_metadata[$tagName]['type'];
}
return 'block';
};
$get_bemto_tag_content_type = function ($tagName) use (&$bemto_tag_metadata) {
if (isset($bemto_tag_metadata[$tagName]) && $bemto_tag_metadata[$tagName]) {
if (isset($bemto_tag_metadata[$tagName]['content_type']) && $bemto_tag_metadata[$tagName]['content_type']) {
return $bemto_tag_metadata[$tagName]['content_type'];
}
if (isset($bemto_tag_metadata[$tagName]['type']) && $bemto_tag_metadata[$tagName]['type']) {
return $bemto_tag_metadata[$tagName]['type'];
}
}
return 'block';
};
if (!isset($GLOBALS['__bemto'])) {
$GLOBALS['__bemto'] = new stdClass();
}
$bemto = $GLOBALS['__bemto'];
$bemto->get_bemto_tag_type = $get_bemto_tag_type;
if (!function_exists('get_bemto_tag_type')) {
function get_bemto_tag_type($tagName) {
global $__bemto;
return call_user_func($__bemto->get_bemto_tag_type, $tagName);
}
}
$bemto->get_bemto_tag_content_type = $get_bemto_tag_content_type;
if (!function_exists('get_bemto_tag_content_type')) {
function get_bemto_tag_content_type($tagName) {
global $__bemto;
return call_user_func($__bemto->get_bemto_tag_content_type, $tagName);
}
}