Skip to content

Commit fbc89f8

Browse files
committed
Merge branch 'develop'
2 parents 30c18ab + f1427a1 commit fbc89f8

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Will be replaced by:
141141
type="text"
142142
name="name"
143143
id="name"
144-
value="{!! e(old('name'), false) !!}"
144+
value="{{ old('name') }}"
145145
>
146146
```
147147

@@ -160,7 +160,7 @@ Will be replaced by:
160160
<input
161161
type="text"
162162
name="name[0]"
163-
value="{!! e(old('name.0'), false) !!}"
163+
value="{{ old('name.0') }}"
164164
>
165165
```
166166

@@ -174,7 +174,7 @@ integrate the replacement function into the output result like this:
174174
<input
175175
type="text"
176176
name="name[0]"
177-
value="{!! e(old(str_replace(['.', '[]', '[', ']'], ['_', '', '.', ''], 'name['.$index.']')), false) !!}"
177+
value="{{ old(str_replace(['.', '[]', '[', ']'], ['_', '', '.', ''], 'name['.$index.']')) }}"
178178
>
179179
```
180180

@@ -200,7 +200,7 @@ Will be replaced by:
200200
type="checkbox"
201201
name="name[]"
202202
value="1"
203-
@checked (in_array('1', (array) old('name')))
203+
@checked(in_array('1', (array) old('name')))
204204
>
205205
```
206206

@@ -217,7 +217,7 @@ It will appear like this:
217217
type="checkbox"
218218
name="name[]"
219219
value="1"
220-
@checked (! old() ? true : in_array('1', (array) old('name')))
220+
@checked(! old() ? true : in_array('1', (array) old('name')))
221221
>
222222
```
223223

@@ -257,7 +257,7 @@ Will be replaced by:
257257
type="text"
258258
name="name"
259259
id="name"
260-
value="{!! e(old('name'), false) !!}"
260+
value="{{ old('name') }}"
261261
>
262262
```
263263

@@ -285,7 +285,7 @@ Will be replaced by:
285285
type="text"
286286
name="name"
287287
id="name"
288-
value="{!! e(old('name'), false) !!}"
288+
value="{{ old('name') }}"
289289
{{-- @TODO CHECK OPTIONS: array_merge($defaultOptions, [
290290
'size' => 50,
291291
'required',

src/Converter.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ protected static function buildFormOpen(string $options): string
201201
$input .= "\n".static::$indent.' @if (strtoupper('.$method.') !== \'GET\')';
202202
$input .= "\n".static::$indent.' @csrf';
203203
$input .= "\n".static::$indent.' @if (strtoupper('.$method.') !== \'POST\')';
204-
$input .= "\n".static::$indent.' @method ('.$method.')';
204+
$input .= "\n".static::$indent.' @method('.$method.')';
205205
$input .= "\n".static::$indent.' @endif';
206206
$input .= "\n".static::$indent.' @endif';
207207

208208
} elseif ($method !== 'GET') {
209209
$input .= "\n".static::$indent.' @csrf';
210210

211211
if ($method !== 'POST') {
212-
$input .= "\n".static::$indent.' @method (\''.$method.'\')';
212+
$input .= "\n".static::$indent.' @method(\''.$method.'\')';
213213
}
214214
}
215215

@@ -366,9 +366,9 @@ protected static function buildSelect(string $name, string $list, string $select
366366
$input .= $placeholderOption;
367367
$input .= static::$indent.' @foreach ('.$list.' as $optionValue => $optionText)'."\n";
368368
$input .= static::$indent.' <option '."\n";
369-
$input .= static::$indent.' value="{!! e($optionValue, false) !!}" '."\n";
370-
$input .= static::$indent.' @selected (in_array($optionValue, (array) ('.static::withOldHelperIfNeeded($name, $selectedValue).')))'."\n";
371-
$input .= static::$indent.' >{!! e($optionText, false) !!}</option>'."\n";
369+
$input .= static::$indent.' value="'.static::escapedEcho('$optionValue').'" '."\n";
370+
$input .= static::$indent.' @selected(in_array($optionValue, (array) ('.static::withOldHelperIfNeeded($name, $selectedValue).')))'."\n";
371+
$input .= static::$indent.' >'.static::escapedEcho('$optionText').'</option>'."\n";
372372
$input .= static::$indent.' @endforeach'."\n";
373373
$input .= static::$indent.'</select>';
374374

@@ -432,7 +432,7 @@ protected static function buildHtmlTagAttributes(array $attributes): string
432432
} elseif ($attrName === 'multiple') {
433433
$attr = '@if ('.$attrValue.') multiple @endif';
434434
} else {
435-
$attr = '@'.$attrName.' ('.$attrValue.')';
435+
$attr = '@'.$attrName.'('.$attrValue.')';
436436
}
437437

438438
} elseif ($attrName === 'class' && preg_match('/^\s*(\[\s*.*\s*\])\s*$/Us', $attrValue, $matches)) {
@@ -461,6 +461,15 @@ protected static function isEmpty(string $value): bool
461461
return \in_array(strtolower($value), ['', "''", '""', 'false', 'null']);
462462
}
463463

464+
protected static function escapedEcho(string $value): string
465+
{
466+
if (static::$escapeWithoutDoubleEncode) {
467+
return '{!! e('.$value.', false) !!}';
468+
}
469+
470+
return '{{ '.$value.' }}';
471+
}
472+
464473
/**
465474
* Examples:
466475
*
@@ -492,11 +501,7 @@ protected static function withEchoIfNeeded(string $value, bool $escape): string
492501
}
493502

494503
if ($escape) {
495-
if (static::$escapeWithoutDoubleEncode) {
496-
return '{!! e('.$value.', false) !!}';
497-
}
498-
499-
return '{{ '.$value.' }}';
504+
return static::escapedEcho($value);
500505
}
501506

502507
return '{!! '.$value.' !!}';

0 commit comments

Comments
 (0)