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
API: Look for templates of namespaced classes in subfolders. #5490
Conversation
test failure :( |
The test failure is caused because |
Needed some |
de98976
to
7967f28
Compare
Needs docs, and the use of arbitrary folders should throw a deprecation notice |
So if templates/SilverStripe/Control/Controller.ss has <% include Foo %> Foo.ss should not live in templates/Includes/?
Can we get the documentation updated alongside the PR? |
Oops, yeah... I hadn't thought that one through. Probably the best best is to allow namespaces on includes, so we could Using namespace semantics would be another option (so that
This PR matches PSR-0 folder conventions, which creates a lot of depth. But, yes, the SilverStripe namespace is only used for projects in the Building on this PR, I'd like to introduce more of a PSR-4 style resolver, where we can map subfolders to namespace prefixes. However, this simpler PR is intended to be the minimum necessary to let us start namespacing controller classes, so I don't want to bloat it.
Yeah, good call. At a minimum I'll put some terse docs into the PR. |
@sminnee |
OK, fair point, but is specifying namespaces a problem, and if so, what would be a better approach? Lumping all includes into a single unnamespaced folder feels far from optimal. We could have flags for selecting which namespaces to search, etc, but I'm worried about pre-emptively bloating out the number of special tags in the template system. |
Ultimately, I guess you could do this, if we expected full namespaces: templates/Includes/Something.ss
templates/App/PageType/Page.ss:
OK for a first-cut? |
I think Also that Includes are heavily used. At least we do as well.. |
This change will mean that SilverStripe\Control\Controller will look for its template in templates/SilverStripe/Control/Controller.ss. In order to preserve some backwards campatibility, non-namespaced classes can have the templates stored in any template subfolder, but once you add a namespace to a class, the namespaced path expression will need to be a subfolder of <module>/templates or themes/<theme>/templates. Layout and Content templates are stil supported as special template type, Includes still functions but is a no-op. Other template subfolders should not be used.
7967f28
to
367a365
Compare
OK, I've made those changes now. Ready for merge? I'd like to get this in so that we can start namespacing core classes that have templates attached. |
Rebasing fixes it. :D |
Merged with 19646d1 |
This change will mean that SilverStripe\Control\Controller will look for its
template in templates/SilverStripe/Control/Controller.ss.
In order to preserve some backwards campatibility, non-namespaced classes
can have the templates stored in any template subfolder, but once you
add a namespace to a class, the namespaced path expression will need to
be a subfolder of /templates or themes//templates.
Layout and Content templates are stil supported as special template type,
Includes still functions but is a no-op. Other template subfolders should
not be used.
To do