jehugaleahsa / mustache-sharp

An extension of the mustache text template engine for .NET.
The Unlicense
306 stars 78 forks source link

#each_top n #60

Open oscaruribe opened 8 years ago

oscaruribe commented 8 years ago

How about an each with a limit? Anyone done that?

blakepell commented 1 year ago

You could copy and paste EachTagDefinition and inside of GetChildContext shim in a counter in foreach (object item in enumerable) that breaks once the limit is hit. The only other thing you need to do is define a the limit as a TagParameter.

I created in a similar manner (the limit I had on it was to stop run away loops rather than being used specified).