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
Refactor email template handling, #43424 #2439
Conversation
{ | ||
return REPLACEMENT_PARAMS; | ||
throw new IllegalStateException(); | ||
} | ||
|
||
public static abstract class ReplacementParam<Type> implements Comparable<ReplacementParam<Type>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An optional idea - make a concrete subclass that takes a Function<Container, Type> as a constructor argument, which would let you pass in a lamba for a slightly leaner syntax than having to do the anonymous inner classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea... I like it. But taking it one step further: implementing a new add()
method in Replacements
that takes the constructor arguments plus lambda is simpler and reduces boilerplate further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@labkey-jeckels you can check out these changes applied to platform and let me know if you have feedback. Other repos coming shortly, but I don't think I need re-review on those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I'm still debating: new add()
method requires ContentType
while ReplacementParam
has a constructor that defaults to ContentType.Plain
. I'm in a "must specify all properties explicitly" mood right now, but maybe it's pedantic in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
In the future, we might think about having addPlain() and addHtml(), perhaps with the latter somehow generating HTMLString instead of maybe-but-not-always HTML encoded Strings, but this seems like a good stopping point for this round.
{ | ||
return REPLACEMENT_PARAMS; | ||
throw new IllegalStateException(); | ||
} | ||
|
||
public static abstract class ReplacementParam<Type> implements Comparable<ReplacementParam<Type>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
In the future, we might think about having addPlain() and addHtml(), perhaps with the latter somehow generating HTMLString instead of maybe-but-not-always HTML encoded Strings, but this seems like a good stopping point for this round.
Thanks. I've spent several hours staring at all the |
Rationale
Issue 43424: Refactor EmailTemplate, etc. describes improvements we should make to
EmailTemplate
and related classes.Changes
EmailTemplate
constructor that takes the critical parameters: name, description, subject, body, content type, and scope. Every email template implementation must make explicit choices for these and none will be forgotten.addCustomReplacements()
method, simplifying constructors and eliminating bookkeeping in all the subclassesadd()
method that takes a lambda to eliminate replacement parameter definition boilerplate codepriority