0

I'm searching a java library that formats/beautifies a given source code snippet. The library should support at least PHP and JavaScript source files.

The reason why i'm searching this is because the code that i generate with my Java application from a REST API description looks not to appealing. I am generating the source files with FreeMarker template engine and i don't want to implement all the formatting logic in the template files. It should be possible that way, but it makes the template files a lot harder to maintain.

klingt.net
  • 2,019
  • 3
  • 18
  • 19

1 Answers1

2

EDIT. After reading your comment, I would say: invoke the external beautifier from within you build script.

For Javascript, this SO question may help. Disclosure: I'm the coauthor of JSBeautifier described in the answer (actually, I work on the Python modules). Essentially, use rhino as the interpreter for JSBeautifier.

For PHP, a quick search brought PHP Beautifier to my attention.

Community
  • 1
  • 1
Stefano Sanfilippo
  • 32,265
  • 7
  • 79
  • 80