Skip to content

Commit 9088bf7

Browse files
author
Pia Sinzig
committed
SHODEVS2-122 add third test case (child component with v-for and v-if)
1 parent 11bcd82 commit 9088bf7

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

src/Compiler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public function convertNode(DOMNode $node): DOMNode
7373

7474
if (in_array($node->nodeName, array_keys($this->components))) {
7575
$currentComponent = $this->components[$node->nodeName];
76+
$this->handleIf($node);
77+
$this->handleFor($node);
7678
if ($node->hasAttributes()) {
7779
/** @var DOMAttr $attribute */
7880
foreach ($node->attributes as $attribute) {
@@ -101,6 +103,7 @@ public function convertNode(DOMNode $node): DOMNode
101103
$include = $this->document->createTextNode('{% include "'.$currentComponent->getPath().'" '.$propsString.'%}');
102104
$node->parentNode->insertBefore($include, $node);
103105
$node->parentNode->removeChild($node);
106+
return $node;
104107
}
105108

106109
$this->stripEventHandlers($node);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
{% for a in listOfProducts %}{% include "/templates/ChildComponent.twig" with { string: "string", product: productA } %}{% endfor %}
3+
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<div>
3+
<ChildComponent v-for="a in listOfProducts" string="string" :product="productA" />
4+
</div>
5+
</template>
6+
<script>
7+
export default {
8+
name: 'component-with-for.vue'
9+
};
10+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
{% if a > 5 %}{% include "/templates/ChildComponent.twig" with { string: "string", product: productA } %}{% endif %}
3+
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<div>
3+
<ChildComponent v-if="a > 5" string="string" :product="productA"/>
4+
</div>
5+
</template>
6+
<script>
7+
export default {
8+
name: 'component-with-if.vue'
9+
};
10+
</script>

0 commit comments

Comments
 (0)