diff --git a/src/Component.php b/src/Component.php index 0ea82b1..54fa4c9 100644 --- a/src/Component.php +++ b/src/Component.php @@ -316,10 +316,10 @@ private function handleRawHtml( DOMNode $node, array $data ) { /** @var DOMElement $node */ if ( $node->hasAttribute( 'v-html' ) ) { - $variableName = $node->getAttribute( 'v-html' ); + $htmlExpression = $node->getAttribute( 'v-html' ); $node->removeAttribute( 'v-html' ); - $this->appendHTML( $node, $data[$variableName] ); + $this->appendHTML( $node, $this->app->evaluateExpression( $htmlExpression, $data ) ); } } diff --git a/tests/php/TemplatingTest.php b/tests/php/TemplatingTest.php index 6657042..cdf6972 100644 --- a/tests/php/TemplatingTest.php +++ b/tests/php/TemplatingTest.php @@ -102,6 +102,15 @@ public function testTemplateWithVhtmlVariable_ReplacesVariableWithGivenValue() { $this->assertSame( '

some value

', $result ); } + public function testTemplateWithVhtmlVariableNestedData_ReplacesVariableWithGivenValue() { + $result = $this->createAndRender( + '
', + [ 'value' => [ 'html' => '

some value

' ] ] + ); + + $this->assertSame( '

some value

', $result ); + } + public function testTemplateWithVhtmlVariableAndAttributeBinding_ReplacesBoth(): void { $result = $this->createAndRender( '
',