Skip to content

Adding the ability to select list items in the context by index. #143

Open
mintchaos wants to merge 2 commits into
defunkt:masterfrom
mintchaos:master
Open

Adding the ability to select list items in the context by index. #143
mintchaos wants to merge 2 commits into
defunkt:masterfrom
mintchaos:master

Conversation

@mintchaos

Copy link
Copy Markdown

This matches the behavior of JS implementations of mustache. Tested
against mustache.js and Hogan.

>>> context = {"data": ['one', 'two', 'three']}
>>> pystache.render("{{ data.0 }}", context)
'one'

Tests added and all previous behavior maintained.

This matches the behavior of JS implementations of mustache. Tested
against mustache.js and Hogan.

>>> context = {"data": ['one', 'two', 'three']}
>>> pystache.render("{{ data.0 }}", context)
'one'
@cjerdonek

Copy link
Copy Markdown
Collaborator

Is this a duplicate of issue #134?

@mintchaos

Copy link
Copy Markdown
Author

@cjerdonek I haven't actually tried the syntax in #134, but I'd imagine that this solves that as well.

@godsarmy

Copy link
Copy Markdown

I think checkin 316c9d4 to support element cherrypick by index with syntax "{{array_key.index}}" is very important feature for this project.

Without this feature, some data could not be rendered from array.

If you try http://mustache.github.io/#demo, you could find that javascript library has already supported this syntax.

@gaastonsr

Copy link
Copy Markdown

This has not been added yet?

@denisvm

denisvm commented Jul 24, 2015

Copy link
Copy Markdown

👍

Very important and interesting feature indeed!

@grayb

grayb commented Jan 14, 2016

Copy link
Copy Markdown

I would like to have this functionality as well.

@amrelhady

Copy link
Copy Markdown

Hi @cjerdonek can this be merged please?

@JiBB

JiBB commented Aug 4, 2016

Copy link
Copy Markdown

I too would love to have this merged in. Any chance that this project will be updated ever again?

@llama

llama commented Nov 8, 2016

Copy link
Copy Markdown

Any reason why this hasn't been merged?

@jeremyjliu

Copy link
Copy Markdown

@cjerdonek is this repo (and this useful PR that it contains) no longer being maintained?

@jeortizquan

Copy link
Copy Markdown

I would like this feature as well.

@jeortizquan

Copy link
Copy Markdown

but also would be nice to access the last element as a function

>>> context = {"data": ['one', 'two', 'three']}
>>> pystache.render("{{ data.first() }}", context)
'one'
>>> pystache.render("{{ data.last() }}", context)
'three'

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.