Whitespace may be also added at start inside script

This commit is contained in:
Adam Nielsen 2019-11-21 15:35:03 +01:00
parent f43f755443
commit cbf8730879
2 changed files with 9 additions and 39 deletions

View File

@ -1,38 +1,7 @@
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<script type="text/javascript">
document.write("<blade " / > );
</script>
<body>
@section('sidebar')
This is the {{ $mater }} sidebar.
@show
<div class="container">
@yield('content')
</div>
<p><span>@lang('Hi')</span></p>
@component('alert')
@slot('title')
Forbidden
@endslot
<strong>Whoops!</strong> Something went wrong!
@endcomponent
@foreach ($users as $user)
@if ($user->type == 1)
@continue
@endif
<li>{{ $user->name }}</li>
@if ($user->number == 5)
@break
@endif
@endforeach
</body>
</html>
<script>
@foreach ($users as $user) {
{
$user - > name
}
} @endforeach
</script>

View File

@ -58,7 +58,8 @@ module.exports = class JSBeautify extends Beautifier
text = text.replace(/\@(?!(?:yield|lang))([^\n\s]*)/ig, "<blade $1 />")
text = beautifyHTML(text, options)
# post script (Workaround)
text = text.replace(/<blade ([^\n\s]*)\s*\/\s*>/ig, "@$1")
# possible whitespaces are added in `script` tag
text = text.replace(/<\s*blade ([^\n\s]*)\s*\/\s*>/ig, "@$1")
text = text.replace(/\(\ \'/ig, "('")
@debug("Beautified HTML: #{text}")
resolve text