Skip to content

Commit 8cf06f9

Browse files
committed
ADD v-html
1 parent d071a1e commit 8cf06f9

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

tests/VueHtmlTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Paneon\VueToTwig\Tests;
4+
5+
class VueHtmlTest extends AbstractTestCase
6+
{
7+
public function testHtml()
8+
{
9+
$component = file_get_contents(__DIR__.'/fixtures/vue-html/html.vue');
10+
$expected = file_get_contents(__DIR__.'/fixtures/vue-html/html.twig');
11+
12+
if(!$component){
13+
self::fail('Component not found.');
14+
return;
15+
}
16+
17+
$compiler = $this->createCompiler($component);
18+
19+
$actual = $compiler->convert();
20+
21+
$this->assertEqualHtml($expected, $actual);
22+
}
23+
}

tests/fixtures/vue-html/html.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% set rawHtml = '<strong>text</strong>' %}
2+
<template>
3+
<div>
4+
<span>
5+
{{ rawHtml|raw }}
6+
</span>
7+
</div>
8+
</template>

tests/fixtures/vue-html/html.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div>
3+
<span v-html="rawHtml" />
4+
</div>
5+
</template>
6+
7+
<twig>
8+
{% set rawHtml = '<strong>text</strong>' %}
9+
</twig>
10+
11+
<script>
12+
export default {
13+
computed: {
14+
rawHtml(){
15+
return '<strong>text</strong>';
16+
},
17+
}
18+
}
19+
</script>

0 commit comments

Comments
 (0)