开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜