With E4X, can I turn off indentation?
If I've got something like:
var x = <div><span>hello</span><span>world</span></div>
and add it to some开发者_JS百科 other expression, it gets rendered as:
<div>
<span>hello</span>
<span>world</span>
</div>
But in HTML, the whitespace between </span>
and <span>
is significant.
Is there a way to turn off the auto-indentation that E4X does?
I'm using Rhino JS, but obviously a standard mechanism would be preferred.
Yes, just set XML.prettyIndent = 0
. If you want to turn off pretty printing entirely, just set XML.prettyPrinting = false
. You can read about more switches on the MDC E4X tutorial.
精彩评论