Answer the question
In order to leave comments, you need to log in
Possible dom in json format?
Good afternoon!
I'm interested in the following question:
Is there any library that allows you to turn such code:
{
html: [{
'body':
{
id: 'test',
OnLoad: function()
{
alert(1);
},
content:
[{
'div':
{
id: 'test2',
content: [
{
'input':
{
type: 'text',
name: 'test',
value: '222'
}
'input':
{
type: 'text',
name: 'test2',
value: '222'
}
}
]
}
}]
}
}]
<html>
<body id = "test">
<div id ="test2">
<input type = "text" name = "test" value = "222" />
<input type = "text" name = "test" value = "222" />
</div>
</body>
</html>
<script>
</script>
Answer the question
In order to leave comments, you need to log in
Yes it is possible, for example BEMJSON :
{
tag : 'div',
attrs : {
id : 'anchor1',
name : 'BEM',
},
content : [
{
tag : 'div',
attrs : {
id : 'anchor2',
name : 'BEM 2',
},
content : 'BEM text'
},
]
}
<div id="anchor1" name="BEM">
<div id="anchor2" name="BEM 2">BEM text</div>
</div>
{
"content": "BEM Block!",
"title": "I am BEM"
}
block( 'someBlock' )(
def()( function () {
var data = this.ctx.data || {};
this.ctx.content = [
{ elem : 'title', content : data.title || 'Empty title' },
{ elem : 'content', content : data.content || 'Empty content' },
];
return applyNext();
} )
);
The absence of such libraries should make you think that it is not worth it
It is possible to modify the nano code as it is almost the same format and made as needed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question