3

Possible Duplicate:
How can I beautify JSON programmatically?

I have build a code generator that gives me a .js file as output with the javascript in it. The code works fine but the only problem is for the indentation.

I have written my code generator in php. Can anyone suggest me a library or something else that will help me to auto indent my generated code in php.

Community
  • 1
  • 1
Ajeet Pratap Maurya
  • 4,244
  • 3
  • 28
  • 46
  • 1
    You might want to take a look as the [js-beautify library](https://github.com/einars/js-beautify) – h2ooooooo Oct 15 '12 at 09:42
  • @h2ooooooo Thanks for that, i have written a php code that generates my `JS` code. so can you just guide me how can I use js-beautify library in my situation – Ajeet Pratap Maurya Oct 15 '12 at 09:45

1 Answers1

1

Try it: They have extensions, library, etc.

http://jsbeautifier.org/

viruskimera
  • 193
  • 16
  • the have extensions but most of them are browser based... anything that fits with php.. – Ajeet Pratap Maurya Oct 15 '12 at 09:59
  • thanks i got the php code for jSbeauty.. it was there on there Github – Ajeet Pratap Maurya Oct 15 '12 at 11:30
  • no problem, yea well.... these kind of tools are good. some times we need them, usually I indent manually or depending environment I am using :) – viruskimera Oct 15 '12 at 11:35
  • actually i needed that beautifier for my code generator.. till now i was managing my code manually so that it gets indented but as the code generator matures..it will be difficult for me to manage code indentation manually.. thanks once again :) – Ajeet Pratap Maurya Oct 15 '12 at 11:42