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 a virtual method "length" on slices, arrays, strings to match JS engines #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dolmen
Copy link

@dolmen dolmen commented Apr 4, 2018

In JavaScript, all arrays have a property length that returns the length of an array. Mustache/Handlebars engines implemented in JS provide this method on array values and some templates originally designed with such engines rely on it. Example: https://jsfiddle.net/u5d5adsa/17/

This patch implements length for slices and arrays. Template like Len: {{ x.length }} now works with data { x: [ 1, 2, 3 ] } => Len: 3

Template like "{{ x.length }}" now works with data { x: [ 1, 2, 3 ] }.
@dolmen

This comment has been minimized.

@dolmen dolmen changed the title Add a virtual method "length" on slices, arrays to match JS engines Add a virtual method "length" on slices, arrays, strings to match JS engines Jun 10, 2018
@dolmen
Copy link
Author

dolmen commented Jun 18, 2018

@aymerick Could you review this change?

@dolmen

This comment has been minimized.

@dolmen

This comment has been minimized.

@dolmen dolmen requested a review from aymerick February 11, 2020 11:12
@jose-anchorlabs
Copy link

ping @aymerick

1 similar comment
@dolmen
Copy link
Author

dolmen commented Jun 17, 2021

ping @aymerick

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