4

I am developing an application using backbone and underscore.

In my HTML page, I have some blocks and they are mixed with some underscore code.

I used the template settings like:

print value: {{ value_name }} excute code: {% code_to_execute %}

so, the source code contains heaps of {% %} blocks and HTML tags.

I tired to use some online JS beautifier site, but they are not doing a good job to format codes into nice clean blocks. I also tried to use sublime's own Reindent, it doesn't help either.

I'm just wondering, if there are any tools exist to format underscore codes efficiently.

Pavan
  • 33,316
  • 7
  • 50
  • 76
JavaScripter
  • 4,282
  • 9
  • 37
  • 45
  • Try 'TidyUp' option in [jsFiddle](http://jsfiddle.net). – Vikram Deshmukh Jan 09 '14 at 07:03
  • Hi srvikram13, I tried that, but didn't get expected result – JavaScripter Jan 09 '14 at 07:13
  • OK that was worth a try. You can also try installing **UniversalIndentGUI** plugin for Notepad++ & press `Ctrl+Alt+Shift+J` to format. Also, try setting the code formatting preferences within the editor you are using. – Vikram Deshmukh Jan 09 '14 at 07:23
  • 2
    Even tho my comment is completely out of context, take it as a word of advice. Do NOT use code on your templates even if it is supported by the engine, it will become a massive problem down the road. I can even recommend you moving into Handlebars which enforces logic-less templates. –  Jan 26 '14 at 14:30
  • I'm used to sublime text2 menu select Edit → Line → Reindent – JSG33kC0d3 Jan 27 '14 at 05:37
  • If Sublime Text is your cup of tee, maybe the package jsformat available at https://github.com/jdc0589/JsFormat would do the job. Install it through the Package Control. – Thalis K. Jun 06 '14 at 15:05
  • Maybe this help - http://stackoverflow.com/questions/3635460/formatting-code-within-notepad (similar to your case). If cant, I think you need to write custom formatter for underscore syntax (or change it to common syntax that used by JSP like <%%>). – hutingung Jul 23 '14 at 00:58

1 Answers1

0

Visual Studio Express is free and will format your code better than anything else I've seen. I might be a bit biased but Visual Studio IMHO is the best IDE Text Editor available. Web Storm is pretty decent as well.

Ctrl+K+D hotkey for quick formatting your text in VS.

Visual Studio Express

Web Storm

I would suggest if you are going to be doing a lot of coding do not rely on internet tools for developing and formatting just get yourself a nice Text Editor.

joverall22
  • 350
  • 1
  • 15