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

Add data metadata (Fix #2450) #2462

Merged
merged 5 commits into from Aug 21, 2016
Merged

Add data metadata (Fix #2450) #2462

merged 5 commits into from Aug 21, 2016

Conversation

ralsina
Copy link
Member

@ralsina ralsina commented Aug 20, 2016

This adds support for a data field in metadata, which loads external data files into a post.

Also, it exposes the post object to shortcodes, so you can do something like this:

A data.json file:

{'links': [
   ['http://foo', 'Foo site'],
   ['http://bar', 'Bar site']
]}

And a post like this:

.. data:: data.json

{{% template %}}
<ul>
% for url, description in post.data('links'):
    <li><a href=${url}>${description}
%endfor
</ul>
{{% /template %}}

And voilá :-)

@ralsina ralsina mentioned this pull request Aug 20, 2016
decode into a python dictionary, and it's keys are available for templates as ``post.data('key')``.

Translated posts can have different values for this field, and the correct one will be
used.
Copy link
Member

@Kwpolska Kwpolska Aug 21, 2016

Choose a reason for hiding this comment

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

Perhaps add a word about shortcodes here?

Copy link
Member Author

@ralsina ralsina Aug 21, 2016

Choose a reason for hiding this comment

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

Good idea, I mentioned this the other way around, but these 2 features go well together.

@Kwpolska
Copy link
Member

Kwpolska commented Aug 21, 2016

LGTM

@ralsina ralsina merged commit c12a6a1 into master Aug 21, 2016
@ralsina ralsina deleted the add-data-metadata branch Aug 21, 2016
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.

None yet

2 participants