Define page templates and layout parts in dedicated Ruby files#1437
Open
simmerz wants to merge 1 commit into
Open
Define page templates and layout parts in dedicated Ruby files#1437simmerz wants to merge 1 commit into
simmerz wants to merge 1 commit into
Conversation
Theme initializers had grown into long lists of parts and view
templates that were hard to read and painful to maintain. This moves
those definitions into app/templates/spina/{theme}/, one file per page
template plus an optional layout.rb for site-wide parts.
PageTemplate.define and LayoutParts.define provide a small DSL for
declaring parts and repeaters. Built-in part types use symbols; custom
parts keep their full class name as a string. At boot, Spina compiles
these files into the same structures the admin already expects, so the
rest of the engine stays largely unchanged.
Part definitions are scoped to their template (and separately for
layout), so the same name can mean different things in different
places without conflict. The old theme.parts and theme.view_templates
configuration still works for now, with a deprecation warning and a
spina:theme:migrate_templates task to convert existing themes. The
migrator backs up the original initializer as .rb.bak so Rails won't
load it.
The install generator and dummy app are updated to use the new layout.
Contributor
|
Woah, that’s a lot of changes! |
Member
Author
|
It needed a bit to change how the parts worked - when I got into it, I realised we needed to solve for conflicts in naming where two pages or the layout have parts with the same name - those shouldn't matter and should work, but wouldn't have. |
Contributor
|
Sheeeeesh! This is a significant change. I like the idea of the abstractions. I think this is a very difficult program to work on architecturally as is. It's hard for me to tell right now as so much of this I still haven't figured out, but I hope that this new organization for the page template metadata will make it easier to contribute new modules to Spina. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Theme initializers had grown into long lists of parts and view templates that were hard to read and painful to maintain. This moves those definitions into app/templates/spina/{theme}/, one file per page template plus an optional layout.rb for site-wide parts. PageTemplate.define and LayoutParts.define provide a small DSL for declaring parts and repeaters. Built-in part types use symbols; custom parts keep their full class name as a string. At boot, Spina compiles these files into the same structures the admin already expects, so the rest of the engine stays largely unchanged.
Part definitions are scoped to their template (and separately for layout), so the same name can mean different things in different places without conflict. The old theme.parts and theme.view_templates configuration still works for now, with a deprecation warning and a spina:theme:migrate_templates task to convert existing themes. The migrator backs up the original initializer as .rb.bak so Rails won't load it.
The install generator and dummy app are updated to use the new layout.