question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow `.length` in addition to `.Count` on arrays

See original GitHub issue

If the context data has a property called myArray of type Array, this expressions renders fine using the javascript version of Handlebars:

{{myArray.length}}

However, when I compile/render with Handlebars.Net, I have to change the expression to {{myArray.Count}} to make it work. I get why that is, but it would be nice if our hbs templates would work in the Handlebars-JS as well, since we use JS-based tools for previewing etc.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johnknoopcommented, Jun 24, 2019

Sure, but then we would have to add the same helper both in C# and javascript.

I can understand that it would feel a bit weird for the compiler to start looking for the string “.length”.

At the same time though… since Handlebars was originally written in Javascript, that sortof becomes the de-facto standard. So I think it would be a good ambition for this project to be able to render anything that can be considered a valid hbs template.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I limit the length of an array in JavaScript?
Therefore, if you want to limit an array to some MAX_SIZE (modifying the existing array instead of creating a new instance) an easy...
Read more >
Program to find sum of elements in a given array
The given code in Python is using the reduce() function from the functools module to calculate the sum of elements in the given...
Read more >
JS Sum of an Array – How to Add the Numbers in a ...
In this article, you will learn how to calculate the sum of all the numbers in a given array using a few different...
Read more >
Array: length - JavaScript - MDN Web Docs
When length is set to a bigger value than the current length, the array is extended by adding empty slots, not actual undefined...
Read more >
How do get the array length? - Programming Questions
I don't see any examples of how to check for an arrays length. In JavaScript you use a method, len=array.length;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found