From 964b9bd3ee546d41bbc17568ffa6b1c217f8c7ef Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Thu, 20 Jan 2022 12:51:29 -0500 Subject: [PATCH] [TwigComponent] make public component properties available directly --- src/LiveComponent/src/Resources/doc/index.rst | 36 +++++++++---------- src/TwigComponent/CHANGELOG.md | 4 +++ src/TwigComponent/src/ComponentRenderer.php | 2 +- src/TwigComponent/src/Resources/doc/index.rst | 14 +++++--- .../components/component_a.html.twig | 2 +- .../templates/components/custom1.html.twig | 2 +- 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/LiveComponent/src/Resources/doc/index.rst b/src/LiveComponent/src/Resources/doc/index.rst index d962afd9c6c..7cc35def450 100644 --- a/src/LiveComponent/src/Resources/doc/index.rst +++ b/src/LiveComponent/src/Resources/doc/index.rst @@ -45,7 +45,7 @@ A real-time product search component might look like this:: @@ -247,19 +247,19 @@ Let's add two inputs to our template:
- Generating a number between {{ this.min }} and {{ this.max }} + Generating a number between {{ min }} and {{ max }} {{ this.randomNumber }}
@@ -316,7 +316,7 @@ happens, add it to the ``data-action`` call: @@ -1024,11 +1024,11 @@ rendered the ``content`` through a Markdown filter from the + >{{post.content}}
-

{{this.post.title}}

- {{this.post.content | markdown_to_html}} +

{{post.title}}

+ {{post.content | markdown_to_html}}
@@ -1142,7 +1142,7 @@ method: data-model="post.content" data-action="live#update" class="{{ this.getError('post.content') ? 'has-error' : '' }}" - >{{ this.post.content }} + >{{ post.content }} Once a component has been validated, the component will “rememeber” that it has been validated. This means that, if you edit a field and the @@ -1162,7 +1162,7 @@ blur the field), update the model via the ``change`` event: data-model="post.content" data-action="change->live#update" class="{{ this.getError('post.content') ? 'has-error' : '' }}" - >{{ this.post.content }} + >{{ post.content }} When the component re-renders, it will signal to the server that this one field should be validated. Like with normal validation, once an @@ -1399,13 +1399,13 @@ In the ``EditPostComponent`` template, you render the type="text" name="post[title]" data-action="live#update" - value="{{ this.post.title }}" + value="{{ post.title }}" > {{ component('markdown_textarea', { name: 'post[content]', label: 'Content', - value: this.post.content + value: post.content }) }}