-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API/ENH: Styler template arguments #15649
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
Comments
Are you familiar with Jinja's template inheritence? I wonder if we inserted some |
Oh, are these I think django gets around that problem by providing a |
In my case the I was actually just looking at how jinja does inheritance, - some |
@chris-b1 can you take a look at TomAugspurger@aafba92 and let me know if that would be sufficient? I moved it into it's own template file to make things easier to work on. I also added I'll add some tests and submit a PR, but it could be a bit. |
@TomAugspurger thanks! Made one inline comment on the blocks. My only question / thing needing docs would be how to actually extend that template. I understand the template syntax ( |
I'll look into this. I think the idea is to use a PrefixLoader or ChoiceLoader.
then if you make a file |
@chris-b1 http://nbviewer.jupyter.org/gist/anonymous/c84f30b41609fef7fd1c06b9fd748729 has an example (using my branch) I'll get things cleaned up and submitted as a PR this week. |
Very nice! Might be nice to wrap the subclassing into some kind of factory function to lessen the jinja2 knowledge required? Roughly def make_styler_subclass(template_folder, visible_template_name):
loader = ChoiceLoader([
FileSystemLoader(template_folder),
PackageLoader("pandas.formats")
])
class MyStyler(pd.formats.style.Styler):
env = Environment(loader=loader)
template = env.get_template(visible_template_name)
return MyStyler |
Closed by #15649 (I think solved everything, just forget to close it). |
Usecase - I have a
Styler
subclass with a new template that I want to pass some arbitrary stuff into - which currently there isn't a great way to do (right now I'm overriding and re-implementing.render()
).Open to suggestions on the api, but I was thinking of adding
template_args
argument that would be passed to the template.xref #11610 (master tracker)
pandas 0.19.2
The text was updated successfully, but these errors were encountered: