Skip to content

Sequence contains more than one element #301

Closed
dotnet/arcade
#16884

Description

@johnknoop

I have a Handlebars template that I've verified works both on http://tryhandlebarsjs.com/ and using the Handlebars Preview extension in VS Code.

However, I get this exception when compiling it with Handlebars.Net:

System.InvalidOperationException: Sequence contains more than one element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at HandlebarsDotNet.Compiler.IteratorBlockAccumulatorContext.IsClosingElement(Expression item)
   at HandlebarsDotNet.Compiler.BlockAccumulator.AccumulateBlock(IEnumerator`1 enumerator, BlockAccumulatorContext context)
   at HandlebarsDotNet.Compiler.BlockAccumulator.AccumulateBlock(IEnumerator`1 enumerator, BlockAccumulatorContext context)
   at HandlebarsDotNet.Compiler.BlockAccumulator.AccumulateBlock(IEnumerator`1 enumerator, BlockAccumulatorContext context)
   at HandlebarsDotNet.Compiler.BlockAccumulator.ConvertTokens(IEnumerable`1 sequence)+MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at HandlebarsDotNet.Compiler.ExpressionBuilder.ConvertTokensToExpressions(IEnumerable`1 tokens)
   at HandlebarsDotNet.Compiler.HandlebarsCompiler.Compile(TextReader source)
   at HandlebarsDotNet.Handlebars.HandlebarsEnvironment.Compile(String template)

This is the template:

<div>
{{#each Items as |item|}}
	<span>
	{{#if item.HasVariants}}
		<strong>
		{{#each item.Variants as |variant|}}
			<i>{{variant.Code}}</i>
		{{/each}}
		</strong>
	{{else}}
		<strong>
		{{item.Code}}
		</strong>
	{{/if}}
	</span>
{{/each}}
</div>

Any ideas?

Activity

  1. rexm commented on May 26, 2019

    @rexm
    Member

    The as |alias| syntax isn't supported yet.

  2. johnknoop commented on May 26, 2019

    @johnknoop
    Author

    I see. Thanks!

  3. added a commit that references this issue on Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions