-
Notifications
You must be signed in to change notification settings - Fork 2.1k
added blocks #3751
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
added blocks #3751
Conversation
Why can't this be done?
You get f not defined
But the next block is inside This build pass the tests, but it's actually not printing anything, ddict inside the block is empty. |
So, you cannot declare a variable inside a block, and expect to use it inside an inner one. Don't know what's the workaround, but as for now should be working. Any tip appreciated. |
A common pattern in the ckan templates is to use a snippet for repeated blocks like this, that makes it easy for an extension to override, and all variables are passed in. We have a separate problem that snippets aren't being cached and slow down rendering, but that can be fixed in another PR. |
@wardi like this? |
@@ -0,0 +1,7 @@ | |||
<tr> | |||
<td>sdfasdf {{ f.id }}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sdfasdf?
{% block resource_data_dictionary_data %} | ||
{% set ddict=h.datastore_dictionary(res.id) %} | ||
{% for f in ddict %} | ||
{% snippet "package/snippets/dictionary_table.html", f=f, h=h %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to pass h. please use a name like 'field' instead of 'f' since inside the snippet it's no longer clear from context what it contains.
{{ form.markdown('info__' ~ loop.index ~ '__notes', | ||
label=_('Description'), id='field-d' ~ loop.index ~ 'notes', | ||
value=f.get('info', {}).get('notes', '')) }} | ||
{% snippet "datastore/snippets/dictionary_form.html", f=f, position=loop.index, form=form %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please pass f
as field
, no need to pass form (the snippet can import it itself)
Should "No newline at end of file" be fixed? |
{% block resource_data_dictionary_data %} | ||
{% set dict=h.datastore_dictionary(res.id) %} | ||
{% for field in dict %} | ||
{% snippet "package/snippets/dictionary_table.html", field=field, h=h %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for h=h here
@amercader @wardi i think this can be backported too |
Unless it's fixing an actual bug, I wouldn't backport changes in the template structure, as we might break extensions. |
Fixes #
Proposed fixes:
Add blocks in datastore plugin templates, dictionary.html and resource_read.html so we can easily customize and expand