templates are very complex, can I contribute?

I think there’s innecesary complexity in templates.

Take for example the $title var, I find it really hard to understand what’s going to be displayed.

It would be simpler to just call the template with $title => get_the_title() directly, or add a Composer for each blade file

Or another example: app.blade.php has another conditional @hasSection

Is there any rational behind that complexity? are you open to take a PR that simplifies the default template?

We’re absolutely open to PRs that work for all the different conditions, or reducing complexity

get_the_title() wouldn’t work everywhere. That complexity is there for a reason to be compatible with all the different scenarios. Wouldn’t it be more complex to introduce a bunch of new view composers that might not be used?

The @hasSection('sidebar') conditional in app.blade.php is actually good practice

It only renders the <aside> wrapper if sidebar content exists. Without it, you’d have empty <aside class="sidebar"></aside> elements on pages without sidebars, which is poor HTML semantics and can cause CSS layout issues

Let me know if this doesn’t sound right

1 Like

Yeah, I think this is a case of “the perfect abstraction” vs “keep it simple”

Sage has great abstractions that keep code minimum and never repeat.

But when used in a project with different layouts, post types and blocks, the abstraction has to be unwrapped to keep code simple.

It’s not a complaint! it’s just from my experience with dozens of projects, I love roots/sage

I just think that more files instead of if/elses is completely fine, even though code repeats, just to keep it simple.

Let me think and show you as code

1 Like