Skip to content
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

feature: add load() to template context #81

Merged
merged 5 commits into from
Jun 12, 2021

Conversation

dhellmann
Copy link
Member

Add a function for loading additional data sources to the template context.
Include documentation with an example of how to use it to combine data
sources that have different formats.

Closes #80

Remove the version-specific items from the tox default environment
list and rely on using the current python version instead. The CI
system will still test the other versions.

Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Sort the imports.

Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Add a function for loading additional data sources to the template
context. Include documentation with an example of how to use it to
combine data sources that have different formats.

Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Signed-off-by: Doug Hellmann <doug@doughellmann.com>

.. code-block:: rst

.. datatemplate:csv:: inventory.csv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to only load data with the load() statement?

If so, add an inline example?

.. datatemplate::

   {% set data = load('inventory.csv') %}
   ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good BTW!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be possible to do that using the nodata loader. https://github.com/sphinx-contrib/datatemplates/blob/master/doc/source/nodata.rst

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I woke up thinking about that.

Copy link

@David-Cowan David-Cowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This meets all my criteria.
Thank You @dhellmann

@dhellmann
Copy link
Member Author

@janbrohl do you have any thoughts or concerns about this?

@dhellmann dhellmann merged commit 6e8bd74 into sphinx-contrib:master Jun 12, 2021
@dhellmann
Copy link
Member Author

This feature is included in release 0.8.1.

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.

Support for multiple data files for a single template
3 participants