-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add support for alternatives to simplates #30
Conversation
In other words, the HTTP method functions in the pyhook are essentially additional algorithm (state chain) functions. |
|
Sure, in the |
But the simplate isn't a separate file, and its implicit variable passing avoids the boilerplate. |
Just one sec, I think I have an implementation that allows simplates to remain as one option for dynamic resources. Almost have a commit here ... |
In the example above it seems to me that you'd be better off using Mako instead of "pyhook" + Jinja: +<%!
"""Show information about a single Team. It might be your team!
"""
from collections import OrderedDict
from aspen import Response
from gratipay.utils import excerpt_intro, get_team, markdown
-[-----------------------------------------------------------------------------]
+%>
+<%
team = get_team(state)
banner = name = team.name
suppress_sidebar = not(team.is_approved or user.ADMIN)
is_team_owner = not user.ANON and team.owner == user.participant.username
-[-----------------------------------------------------------------------------]
-{% extends "templates/team-base.html" %}
+%>
+<%inherit file="templates/team-base.html"/>
+[… the rest of the Jinja template converted to Mako …] |
62772f2
to
d316d53
Compare
d316d53
to
e1bb5a8
Compare
Check out e1bb5a8. That allows us to register different dynamic classes based on the file extension, which means we could have plugins for Pyhooks, Mako, Simplates, or whatever. |
Actually, though, I think we should bake in the pyhook concept, because it's optional. If you don't want to use it, just don't have a |
The inverse could also be possible: only have a |
Looks fine to me. We'll need to further modify the dispatcher to detect conflicting dynamic resources. You dropped the |
Do you think we should try to get this done before 1.0? Seems like if we're planning to still support simplates as an option then it's lower priority than if we were going to drop simplates entirely. |
How about we try to merge this PR sooner rather than later, and then I/we can add the pyhooks feature in a later PR post-1.0? |
Gah ... or maybe pre-1.0? I think I'm going to turn next to the Flask and Django plugins, and I might rather say "pyhooks" than "simplates" in the docs for those. Hmm ... |
@Changaco Do you want to keep simplates? Could you use pyhooks to implement |
Yes, until I've determined from experience that they can be entirely replaced by the alternatives without leading to boilerplate or other unpleasantness. Dropping simplates now would require more work to port liberapay to something else, which would make it harder to get Pando running in production before the 1.0 announcement.
Support for
Yes, but not as a priority, so only if we have the time. |
@kaguillera and I just worked through another example, Gratipay's reconciliation dashboard. Here's what we came up with. This illustrates nesting of pyhooks. The request processing state chain is extended with the |
(The |
As I said earlier, putting stuff in the |
Since that's really what they were testing.
@Changaco Ready for review. |
Looks okay to me. I've renamed the PR to match what it actually does. The changes aren't enough to implement your multiple-files idea (that would require bigger changes to the dispatcher), but they should allow implementing my original proposal from #27, as well as Mako templates, so I guess it's a good first step. |
The simplate file format does not play will with the tooling ecosystem. This PR looks to replace simplates with multiple files per resource, while preserving filesystem dispatch. See #27.