Skip to content

Instantly share code, notes, and snippets.

@brnpimentel
Created December 18, 2017 13:37
Show Gist options
  • Save brnpimentel/3660b71dbc68691cdc8ac41cec379e2f to your computer and use it in GitHub Desktop.
Save brnpimentel/3660b71dbc68691cdc8ac41cec379e2f to your computer and use it in GitHub Desktop.
JS Beautify hack to works with blade directives (laravel)
function style_html(html_source, options, js_beautify, css_beautify) {
html_source = html_source.replace(/\@([^\n\s]*)/ig, "<blade $1/>");
...
sweet_code = sweet_code.replace(/<blade ([^\n]*)\/>/ig, "@$1");
sweet_code = sweet_code.replace(/\(\ \'/ig, "('");
...
return sweet_code;
}
@mpryvkin
Copy link

mpryvkin commented Apr 21, 2018

@fzldn, thanks for the snippet, works great. This part of the regex [^\n] needs to be changed to [^\r\n] to remove CR 0x0D character on Windows.

I added some other minor changes and created this gist based on your code.

@fzldn
Copy link

fzldn commented Aug 31, 2018

I also make the gist for js-beautify hack for HookyQR.beautify version 1.4.2 here the gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment