Skip to content

Commit 3d054e9

Browse files
authored
Merge pull request #19 from Paneon/master
Update master
2 parents 072a1a1 + 34a4238 commit 3d054e9

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

src/Compiler.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,14 @@ private function handleAttributeBinding(DOMElement $node)
387387
*/
388388
$templateStringContent = $matches['content'];
389389

390-
$templateStringContent = preg_replace(
391-
'/\$\{([^}]+)\}/',
392-
'{{ $1 }}',
393-
$templateStringContent
394-
);
390+
preg_match_all('/\$\{([^}]+)\}/', $templateStringContent, $matches, PREG_SET_ORDER);
391+
foreach ($matches as $match) {
392+
$templateStringContent = str_replace(
393+
$match[0],
394+
'{{ ' . $this->builder->refactorCondition($match[1]) . ' }}',
395+
$templateStringContent
396+
);
397+
}
395398

396399
$dynamicValues[] = $templateStringContent;
397400
} else {
@@ -404,7 +407,7 @@ private function handleAttributeBinding(DOMElement $node)
404407
}
405408

406409
$node->setAttribute(
407-
$name,
410+
$name === 'src' ? Replacements::getSanitizedConstant('SRC_ATTRIBUTE_NAME') : $name,
408411
$this->implodeAttributeValue($name, $dynamicValues, $staticValues)
409412
);
410413
}

src/Models/Replacements.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ abstract class Replacements extends BasicEnum
1212
public const SMALLER = '<';
1313
public const AMPERSAND = '&';
1414
public const PIPE = '|';
15+
public const SRC_ATTRIBUTE_NAME = 'src';
1516

1617
/**
1718
* Removes all instances of replacements from target
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="block {{class|default('')}}">
2+
<div style="width: {{ 100 / items|length }}%;">
3+
Hello World
4+
</div>
5+
</div>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="block">
3+
<div :style="`width: ${100 / items.length}%;`">
4+
Hello World
5+
</div>
6+
</div>
7+
</template>
8+
9+
<script>
10+
export default {
11+
props: {
12+
items: {
13+
type: Array,
14+
required: true,
15+
},
16+
},
17+
};
18+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="{{class|default('')}}">
2+
<img src="{{isBool ? varA : varB}}">
3+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div>
3+
<img :src="isBool ? varA : varB">
4+
</div>
5+
</template>

0 commit comments

Comments
 (0)