Skip to content

Create a properly-architected layout architecture for the view layer #18

@markshust

Description

@markshust

Problem

I've had a few requests to create a proper layout system for the view layer, and I would absolutely like to build this. It should be part of the 1.0 release.

I really like Magento's layout structure and approach, but don't see any reason we'd need XML to do this. I think we can accomplish this with PHP attributes, similar to how we create routes and etc. This aligns with the Marko premise of keeping logic all co-located into a single area.

I'm thinking we can define layouts and/or views on the related PHP controller class, and that will determine which layout to render.

How would separate blocks also be rendered on a page? Should we have Block classes, or is that overkill?

I'll do my own digging, but would definitely love the feedback of the community with this request though, as it's a big addition.

Proposed Solution

New layout or view-layout package which creates this capability. Perhaps it can also just be an addition to the main view package, as it is likely that anyone creating templates will also need layouts.

Alternatives Considered

An alternative is to do something like Blade layouts, where the templates themselves call the related layout(s) and/or component(s). This seems a bit backward-thinking to me, as I think the layout should be defined first, then the template to render, but would like to hear what you think. Perhaps we can have two options.

Package

view

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions