-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat(whiskers): add read_file function #217
Conversation
Code seems fine, though I'm thinking it might be more predictable to go from the path of the tera file itself? Thoughts? |
What do you mean? That is what it does. It uses the parent of the Whiskers template as the root for resolving paths. |
Usage of |
Yay! Figured out why tests were failing - turns out whitespace control is undocumented for usage in expressions, but you can do it (Keats/tera#919)! |
this stops the code panicking on `whiskers -` when read_file is used, and as a side-effect also cleans up the clone dance in read_file_handler.
adds context to errors returned from the `template_directory` function. without this, we get a platform-specific error message that makes testing harder.
Co-authored-by: backwardspy <[email protected]>
Adds a
read_file
function for reading the raw contents of files into templates. Workaround for usecases which would usually involve theinclude
builtin but we cannot use it as a) it requires static paths (e.g. you can do{% include "abc.tera" %}
but not{% include flavor.identifier ~ ".tera" %}
) and b) it preloads all template paths provided by the glob which doesn't allow for the various encodings Whiskers itself supports. EDIT: Also useful for places where including the contents of theLICENSE
file is needed.