dox Executable Documentation

Nested model

Nested property

Given the model '{"post":{"author":"John", "text":"Hello World"}}'
When I render '<div property="post"><div property="author">Me</div><div property="text">Hi</div></div>'
Then the result should be '<div property="post"><div property="author">John</div><div property="text">Hello World</div></div>'

Leaf inside leaf

Given the model '{"email":{"href":""}, "name":"Test"}'
When I render '<a property="email" href=""><span property="name">Name</span></a>'
Then the result should be '<a property="email" href=""><span property="name">Test</span></a>'

Property inside undefined node

Given the model '{"text":"Hello World"}'
When I render 'Hello <div property="undefined"><span property="text">World</span></div>'
Then the result should be 'Hello <div property="undefined"><span property="text">Hello World</span></div>'

Deeply nested model

Given the model '{ "post": { "text": "Hello World!", "author": { "name": "Timmy Tester", "image": { "alt": "Timmys Image", "src": "" }, "email": { "href": "" } } } }'
When I render ' <div property="post"> <div property="author"> <img property="image" src="" alt="Nothing"/> <a property="email" href=""> <span property="name">John Doe</span> </a> </div> <span property="text">Some Text</span> </div>'
Then the result should be ' <div property="post"> <div property="author"> <img property="image" src="" alt="Timmys Image"/> <a property="email" href=""> <span property="name">Timmy Tester</span> </a> </div> <span property="text">Hello World!</span> </div>'

Scalar model with inner properties

Given the model '{"nonObject":1}'
When I render ' <div property="nonObject"><span property="ignore"><span property="me">Nothing</span></span></div> <div property="nonObject">One</div>'
Then the result should be ' <div property="nonObject">1</div> <div property="nonObject">1</div>'

Inner false or null values

Given the model '{ "outer": { "no": false, "empty": null, "yes": true } }'
When I render ' <div property="outer"> <span property="no">No</span> <span property="empty">Empty</span> <span property="yes">Yes</span> </div>'
Then the result should be ' <div property="outer"> <span property="yes">Yes</span> </div>'

Lexical scope

Given the model '{ "outer": 1, "inner": 1, "local": 1, "list": [ { "inner": 2, "local": 2, "child": { "local": 3, "own": 4 } } ] }'
When I render ' <div property="outer"></div> <div property="inner"></div> <div property="local"></div> <div property="list"> <div property="outer"></div> <div property="inner"></div> <div property="local"></div> <div property="child"> <div property="outer"></div> <div property="inner"></div> <div property="local"></div> <div property="own"></div> </div> </div> '
Then the result should be ' <div property="outer">1</div> <div property="inner">1</div> <div property="local">1</div> <div property="list"> <div property="outer">1</div> <div property="inner">2</div> <div property="local">2</div> <div property="child"> <div property="outer">1</div> <div property="inner">2</div> <div property="local">3</div> <div property="own">4</div> </div> </div> '

Properties inside true value

Given the model '{"isTrue":true, "message":"Hello World"}'
When I render '<div property="isTrue"><div property="message">Hi</div></div>'
Then the result should be '<div property="isTrue"><div property="message">Hello World</div></div>'

Map object

Given the model object new Map(array('one' => new Map(array('two' => 'three'))))
When I render '<div property="one"><div property="two">Hello</div></div>'
Then the result should be '<div property="one"><div property="two">three</div></div>'