Skip to content

[Twig] Tweaking docs for new HTML syntax #799

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

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? no
New feature? no
Tickets None
License MIT

Just following up with a few more tweaks to @WebMamba's docs in #792.

Cheers!

@WebMamba
Copy link
Contributor

Thanks @weaverryan! Looks good to me! 😁

// withActions will be set to true
<twig:Alert type="info" message="hello!" withActions />

To pass in a dynamic value, prefix the attribute with ``:`` or use the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking ... is this convention based on the : prefix imposed somehow to us? Otherwise, it looks strange to introduce this new convention when we all know and use the {{ ... }} to output the value of variables or expressions. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's borrowed from Vue, and also is used Blade Components. I agree that it feels like an "extra" thing, but it's also a very common syntax to see.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can still use the {{ ... }}, the : is just a small shortcut.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so this is a very common syntax outside of Symfony. Then, it makes sense to have it too. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I found that it is more or less "needed" when you want to pass non-string values - like booleans or arrays:

<twig:Alert :showClose="false" :messages="['hello', 'world']" />

Passing Props as HTML Attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Passing props is done with HTML attributes. For example if you have this component::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Passing props is done with HTML attributes. For example if you have this component::
Passing props is done with HTML attributes. For example if you have this component:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdreesen actually, the double :: is needed. We use RST format instead of Markdown. code blocks are declared as .. code-block:: php. But since we have so many PHP code blocks, it's boring to do that. That's why we use a RST trick to tell it that any code following two :: is to be considered as PHP code.

Copy link
Contributor

@jdreesen jdreesen Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know that. Thx for the explanation.

@weaverryan weaverryan force-pushed the twig-html-syntax-docs-tweaks branch from 3fee544 to 6691401 Compare April 18, 2023 20:04
@weaverryan weaverryan merged commit a51d9c9 into symfony:2.x Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants