Skip to content
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

[Twig] add a component name/template : "namespace" notation #460

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

kbond
Copy link
Member

@kbond kbond commented Sep 12, 2022

Q A
Bug fix? no
New feature? yes
Tickets #108
License MIT

Proposes : as a namespace separator for component names. The default template replaces the : with / to create sub-directories. A component with the name form:input's default template would be templates/components/form/input.html.twig.

Don't believe this would be a BC break. If someone is using the : notation already, they likely would have customized the template.

@kbond kbond changed the title [Twig] add a component name/template "namespace" notation [Twig] document using / as a namespace separator in the component name Sep 12, 2022
@kbond
Copy link
Member Author

kbond commented Sep 12, 2022

Adjusted this PR to just document/test using / as the namespace separator instead of introducing a custom notation.

@veewee
Copy link
Contributor

veewee commented Sep 13, 2022

I've adjusted this PR to just document/test using / in the component's name as a namespace separator. After discussing with @weaverryan, we'd like avoid a custom notation for now.

That was the first thing I tried and it makes a lot of sense to use that as a separator - yet it doesn't work for live components.
Live components have their own URLs to refresh the content on the page. This URL doesn't allow the name of the live template to contain a /. This means that if you use / as the namespace separator, you won't be able to apply the same standard to live components. (Unless we make it possible in the router)

That is why I went with :. Not saying it's the best, but the reasoning behind that separator could be:

  • the old way twig did includes.
  • in line with how you'dd namespace in html (xml) <atom:button />

@kbond
Copy link
Member Author

kbond commented Sep 13, 2022

yet it doesn't work for live components.

Ah good point!

in line with how you'dd namespace in html (xml) <atom:button />

Yeah, we'd like to add an html parser in the future. Slashes wouldn't work with this.

@kbond kbond changed the title [Twig] document using / as a namespace separator in the component name [Twig] add a component name/template : "namespace" notation Sep 14, 2022
@kbond
Copy link
Member Author

kbond commented Sep 14, 2022

Ok, switched back to : for the reasons stated by @veewee.

@weaverryan
Copy link
Member

Thanks Kevin!

@weaverryan weaverryan merged commit bc72ec7 into symfony:2.x Sep 16, 2022
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.

3 participants