-
Notifications
You must be signed in to change notification settings - Fork 57
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
Accept Template along with template path #112
Comments
Would you be able to work on a patch for this? I don't typically pass around |
I came here to ask for the same feature - not because I load templates from my database, but because when you're first trying out the library, or when you're doing development in general, it'd be convenient to pass a test string first and then promote it to a template file later. I think only accepting body content in the form of template files is unnecessarily restrictive. |
Can you folks try ecdaad7 ? Thanks. :) |
I looked at the commit, but I didn't understand the change. I installed branch I don't understand what has changed or how to use that change. |
The change adds support for Template objects... but, wait, when you say "message string", what exactly do you mean by that? What is the Python data type of that? |
I would like the ability to simply hand
The simplest and most intuitive use case. |
By what mechanism would the method determine whether this |
I don't have a good answer. The fact that the existing API expects a string containing a template name + the need to maintain backwards compatibility kind of kills the opportunity for the most obvious interface, which would be to simply pass a string containing the actual message. You could branch on whether the string ends with ".slack", but that's fragile. You could accept a flag in kwargs indicating the first arg is a message rather than template name, but that's ugly. Perhaps it would make sense to export an alternative function like from_string() - though that's also ugly. If this request doesn't fit in with your design or plans, feel free to ignore it. I've already started using my own slack messaging library based on your |
Noted - thanks for the background and context. However, thinking about it for a bit, believe that the most obvious interface (as you put it) is the template path, not a string, ie. a conscious analogy or parallel to Django's regular rendering methods which take template paths precisely to avoid all of the ugliness of formatting potentially quite complicated strings in Python code... and to gain all the advantages of template filters and suchforth. |
Hi,
Very nice library, in our case we load templates from the database it would be great if we could pass Template object to slack_message() instead of just a pathname to the template.
The text was updated successfully, but these errors were encountered: