Skip to content

Global Template vars refactor - #1026

Merged
waylan merged 3 commits into
mkdocs:masterfrom
waylan:global_vars
Sep 28, 2016
Merged

waylan merged 3 commits into
mkdocs:masterfrom
waylan:global_vars

Conversation

@waylan

@waylan waylan commented Aug 15, 2016

Copy link
Copy Markdown
Contributor

This is a continuation of the work started in #921. That PR addressed the page context. This addresses the global context (see #874 for more info).

Still a lot of work to do on this. I started by rebasing #681 and gracefully deprecating include_nav and include_next_previous rather than removing them. I've left the individual commits for now so you can compare my changes to the original.

@waylan waylan added this to the 0.16 milestone Aug 15, 2016
@waylan
waylan force-pushed the global_vars branch 2 times, most recently from 990191a to 0510fa2 Compare August 15, 2016 18:29
Any template variables which mirrored a config setting have been deprecated
and should be accessed via the coresponding config template variable.

This resolves the rest of mkdocs#874.
@waylan

waylan commented Aug 16, 2016 •

Copy link
Copy Markdown
Contributor Author

I've cleaned up the commit history and finished the global template variable refactor. Assuming all the tests pass, this should be ready to go.

The one concern I have is that three variables still exist both in the config and as global variables: favicon, extra_css, and extra_javascript. In build.py we are doing the following:

site_favicon = nav.url_context.make_relative('/' + config['site_favicon'])
extra_javascript = utils.create_media_urls(nav, config['extra_javascript'])
extra_css = utils.create_media_urls(nav, config['extra_css'])

So the values differ between the config settings and the template variables. I have highlighted this difference in the docs, but wanted to point it out here in case we should be doing something different. It occurs to me that we could create some sort of object (similar to the page object) which contained local_path and url attributes for each object. That way, the config variable would hold both pieces of data side-by-side. However, that feels a little too complex for this already big change. Perhaps that could be done another time.

This was referenced Aug 17, 2016
Templates need only include `{{ base_url }}/img/favicon.ico` and
users only need to create a file at `img/favicon.ico` in their
`docs_dir`.

Fixes mkdocs#725.
@waylan

waylan commented Aug 18, 2016

Copy link
Copy Markdown
Contributor Author

In light of #725 (which I had forgotten about), I just added a commit which deprecates favicon, leaving extra_css and extra_javascript as the only two outliers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants