I am wondering if anybody knows of a canonical way to represent HTML
in a json-like data structure (e.g. Ruby hashes/arrays, Python
dictionaries/lists, etc.).
I am writing a testing tool for Ruby on Rails, and while we don't use
HAML yet in our code, I would like to render the web pages from our
functional tests in HAML. I was hoping to first generate some
intermediate result like below in JSON, then I'd convert that to
HAML. Having the intermediate result would allow other cool features,
such as rendering just part of an HTML page to show the functional
tests are working, with visual queues.
Here is a rough stab at a JSON format for XML:
{
'TAG': 'div',
'ATTRS': {
'id': 'profile',
},
'CHILDREN': [
{
'TAG': 'div',
'ATTRS': {
'class': 'left column',
},
'CHILDREN': [
{
'TAG': 'div',
'ATTRS': {
'id': 'date',
},
'TEXT': '<%= print date %>'
},
{
'TAG': 'div',
'ATTRS': {
'id': 'address',
},
'TEXT': '<%= current_user.address %>'
},
],
},
{
'TAG': 'div',
'ATTRS': {
'class': 'right column',
},
'CHILDREN': [
{
'TAG': 'div',
'ATTRS': {
'id': 'email',
},
'TEXT': '<%= current_user.email %>'
},
{
'TAG': 'div',
'ATTRS': {
'id': 'bio',
},
'TEXT': '<%= current_user.bio %>'
},
],
},
],
}
--
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.