-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ability to use partials in a partials directory and underscored #305
Comments
If you want to use it like that you'll need to specify the partial directory, like so:
|
Yup, but that's not how it's documented (or, I'm guessing, how it's intended to work). You don't need to specifiy the partials directory either, just the underscore is enough. Here is a fix to work as described in cms/src/Tags/Partial.php line 34, add:
|
In that case a PR to the docs would be nice :-) In bigger projects you will quickly get to that point, where you may have partials with the exact same name, just living in different directories. As I see it, the behavior is expected as it does work now :-) |
The initial idea was to do it one way or the other. The underscores are so you can tell which views are partials when mixed in with everything else. We can add support for doing both, I suppose. |
I wasn't sure if it was a design decision, maybe just the docs need tweaking to make it clearer as it feels like a bug at the moment. My use case is smalled partials (like literally for a button, I use this a lot with Tailwind), I am using an _ and then larger things like header/footer without. That's very much a preference though, and it's easy for me to just add the _ to the partial tag. |
I actually can't recreate this. 🤔 Using Using Using |
Hmm, I just tried again on 3.0.5 - same That's with
I don't understand how "Using {{ partial:foo }} with partials/_foo.antlers.html works fine." works, as the code in |
Oh my bad, I copied @damcclean's example |
The docs at https://statamic.dev/views#templates say to prefix partials with _underscores, and "You don’t need to include the underscore in your partial tag.".
Using
{{ partial:foo }}
withpartials/foo.antlers.html
works fine.Using
{{ partial:_foo }}
withpartials/_foo.antlers.html
works fine.Using
{{ partial:foo }}
withpartials/_foo.antlers.html
breaks with the error:Running 3.0.2
The text was updated successfully, but these errors were encountered: