Skip to content

Bindjson Tag#1

Open
npx wants to merge 2 commits intoflosch:masterfrom
npx:bindjson
Open

Bindjson Tag#1
npx wants to merge 2 commits intoflosch:masterfrom
npx:bindjson

Conversation

@npx
Copy link
Copy Markdown

@npx npx commented Oct 17, 2016

Hello and thank you for pongo. I love Django and this was exactly what I needed!

I added a tag, that allows binding a json data file to a variable local to the block the tag surrounds.

Example:

{% bindjson "../data/data.json" as data %}
  <h1>{{ data.category }}</h1>
  <ul>
    {% for item in data.items %}
    <li>{{ item.caption }}</li>
    {% endfor %}  
  </ul>
{% endbindjson %}

I would love to add tests, but I am relatively new to Go and am not quite sure how to mock the file reading and test for syntax errors in my tag's arguments. Maybe you have some pointers into the right direction?

Please let me know if you consider adding it :)

Kind Regards

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.

1 participant