###Генерация вёрстки
/// <div class="oh"><p>hi</p></div>
var traversedAST = [{
type: 'tag',
name: 'div',
attrs: {
class: {
data: {
type: 'text',
value: 'oh'
}
}
},
selfclosing: false,
children: [
{
type: 'tag',
name: 'p',
attrs: {},
selfclosing: false,
children: [
{
type: 'text',
data: {
type: 'text',
value: 'hi'
}
raw: 'hi'
}
]
}
]
}];
//Генерация вёрстки из AST шаблона
var html = tmpl.process(traversedAST, {}); // <div class="oh">123</div>
####Генерация с помощью функции AST
function ast(___helpers) {
var modules = __helpers.modules,
decorators = __helpers.decorators;
var result = [
TMPL.createTag({
name: 'div',
selfclosing: false,
attrs: {
class: {
data: {
type: 'text',
value: 'oh'
}
}
},
children: [
TMPL.createTag({
name: 'p',
selfclosing: 'false',
attrs: {},
children: [
TMPL.createTextNode({
'hi'
})
]
})
]
})
];
}
//Генерация вёрстки из AST функции
var html = tmpl.process(ast(__helpers), {}); // <div class="oh"><p>hi</p></div>
####Генерация с помощью функции конкатенации
function ast(data, ___helpers, includes) {
var modules = __helpers.modules,
partial = __helpers.partial,
decorators = __helpers.decorators,
__getexpression = __helpers.getexpression;
var result = '<div class="oh"><p>hi</p></div>';
return result;
}
var html = ast({}, __helpers, includes); // <div class="oh"><p>hi</p></div>