Ivan Gretsky Posted January 18, 2022 Share Posted January 18, 2022 Good evening @teppo and everyone! I am getting acquainted with partials. I like the way to include them with chaining interface <?= $partials->common->summaryblock() ?> much better than the include way (opinionated ?) <?php include 'partials/common/summaryblock.php'; ?> One problem here is that I have to add those brackets, as without them I get the file path. IMHO the rendered markup should be the default to be more in line with ProcessWire way. But my main problem is that I cannot use dashes (or dots) in partial file names. Is there a way to get around this limitation? Maybe something like this... <?= $partials->get('common/summary-block') ?> In simple cases it is just a matter of changing preferences, but if we get to partials with arguments, that seem to be the deal breaker, as we cannot do this: <?= $partials->common->summary-block(['heading' => 'Hi!']) ?> Link to comment Share on other sites More sharing options...
teppo Posted January 18, 2022 Share Posted January 18, 2022 4 hours ago, Ivan Gretsky said: One problem here is that I have to add those brackets, as without them I get the file path. IMHO the rendered markup should be the default to be more in line with ProcessWire way. A bit of background: rendering partials (using the partial name as method) is a relatively new addition, while including partials with chained syntax (<?php include $partials->common->summary ?>) has been an option since the very beginning. I don't have a strong opinion about what should be the default behaviour, but the main reason why I likely won't change this is that it would potentially break a lot of sites ? 4 hours ago, Ivan Gretsky said: But my main problem is that I cannot use dashes (or dots) in partial file names. Is there a way to get around this limitation? Maybe something like this... <?= $partials->get('common/summary-block') ?> In simple cases it is just a matter of changing preferences, but if we get to partials with arguments, that seem to be the deal breaker, as we cannot do this: <?= $partials->common->summary-block(['heading' => 'Hi!']) ?> At this point I would recommend against partial names with dots or dashes. Personally I tend to use snake_case for naming, as I find that the most sensible option: dashes or dots won't work, and camelCase and PascalCase are prone to errors (although it's customary to use them in class names). It is actually possible to access properties with dashes as well, but it's not exactly pretty: <?= $partials->common->{'summary-block'}(['heading' => 'Hi!']) ?>. Extending $partials->get() with support for paths does seem like a good idea, though, so I'll add this to my todo list ? 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted January 20, 2022 Author Share Posted January 20, 2022 On 1/18/2022 at 11:28 PM, teppo said: Extending $partials->get() with support for paths does seem like a good idea, though, so I'll add this to my todo list ? I would love to see that todo list) It might be a good way to create a github issue for each item and group them with projects or project boards. Should I create an issue based on this topic? 1 Link to comment Share on other sites More sharing options...
teppo Posted January 20, 2022 Share Posted January 20, 2022 8 hours ago, Ivan Gretsky said: Should I create an issue based on this topic? Sure, that'd be great ? Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted January 21, 2022 Author Share Posted January 21, 2022 Done. I wish we could have the roadmap clearly visible in github. I you agree, maybe do start adding issues there. Thanks! Link to comment Share on other sites More sharing options...
teppo Posted March 1, 2022 Share Posted March 1, 2022 Cross-posting here that $partials->get('path/to/partial') is now supported in Wireframe 0.22.0, along with new method $partials->render('path/to/partial'). More details in the docs: https://wireframe-framework.com/docs/view/partials/. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now