开发者

With E4X, can I turn off indentation?

开发者 https://www.devze.com 2023-02-03 11:32 出处:网络
If I\'ve got something like: var x = <div><span>hello</span><span>world</span></div>

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

精彩评论

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