Skip to content

Minor clarifications to TwigComponent doc examples #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/TwigComponent/src/Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ And (2) a corresponding template:
.. code-block:: twig

{# templates/components/alert.html.twig #}
<div class="alert alert-{{ type }}">
{{ message }}
<div class="alert alert-{{ this.type }}">
{{ this.message }}
</div>

Done! Now render it wherever you want:
Expand Down Expand Up @@ -132,14 +132,11 @@ public property for each:

In the template, the ``AlertComponent`` instance is available via
the ``this`` variable and public properties are available directly.
Use them to render the two new properties:
Access the variable to render the two new properties:

.. code-block:: twig

<div class="alert alert-{{ type }}">
{{ message }}

{# Same as above, but using "this", which is the component object #}
<div class="alert alert-{{ this.type }}">
{{ this.message }}
</div>

Expand Down Expand Up @@ -188,9 +185,9 @@ component's name (``alert``) and a ``template`` tag attribute
The mount() Method
~~~~~~~~~~~~~~~~~~

If, for some reason, you don't want an option to the ``component()``
function to be set directly onto a property, you can, instead, create a
``mount()`` method in your component::
If, for some reason, you don't want an option passed to the
``component()`` function to be set directly onto a property, you can,
instead, create a ``mount()`` method in your component::

// src/Components/AlertComponent.php
// ...
Expand Down