Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated tag & children attributes
Deprecated tag & children attributes : '<>' to be used instead of 'tag' and 'html' to be used instead of 'children'.
- Loading branch information
Showing
5 changed files
with
78 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
|
||
//Test nested dynamic children | ||
// calls json2html recusively | ||
var nested = {"Name": "Parent", "Children": [{"Name": "Child1"}, {"Name": "Child1"}]}; | ||
var nested = {"name":"parent", "children": [{"name": "child1"}, {"name": "child2"}]}; | ||
|
||
var transform_parent = [ | ||
{"tag":"span", "html":"${Name}"}, | ||
{"tag":"ul", children:function(){return(json2html.transform(this.Children, transform_child));}} | ||
]; | ||
var transforms = { | ||
"parent":[ | ||
{"<>":"span", "html":"${name}"}, | ||
{"<>":"ul","html":function(){return(json2html.transform(this.children, transforms.child));}} | ||
], | ||
|
||
var transform_child = | ||
{"tag":"li", children:[ | ||
{"tag": "b", "html":"${Name}"} | ||
]}; | ||
var html = json2html.transform(nested,transform_parent); | ||
"child":{"<>":"li", children:[ | ||
{"<>": "b", "html":"${name}"} | ||
]} | ||
}; | ||
|
||
var html = json2html.transform(nested,transforms.parent); | ||
|
||
document.write('<h1>Nested Test</h1>'+ html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters