Skip to content

Whitespace in opening Partial Block expression? #217

@leekelleher

Description

@leekelleher

Reading from the Handlebars specs, the opening Partial Block expressions appear to allow whitespace.

http://handlebarsjs.com/partials.html#partial-block

{{#> myPartial }}
  Failover content
{{/myPartial}}

This currently throws an exception, (I'm using the latest bleeding-edge build, v1.9.0-ci, from commit: a56efe8 - I haven't tested any other version/release).

Reached end of template before block expression
[HandlebarsCompilerException: Reached end of template before block expression '' was closed]
   HandlebarsDotNet.Compiler.BlockAccumulator.AccumulateBlock(IEnumerator`1 enumerator, BlockAccumulatorContext context) +411
   HandlebarsDotNet.Compiler.<ConvertTokens>d__3.MoveNext() +389
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +333
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   HandlebarsDotNet.Compiler.BlockAccumulator.Accumulate(IEnumerable`1 tokens, HandlebarsConfiguration configuration) +97
   HandlebarsDotNet.Compiler.ExpressionBuilder.ConvertTokensToExpressions(IEnumerable`1 tokens) +268
   HandlebarsDotNet.Compiler.HandlebarsCompiler.CompileView(String templatePath) +576
   HandlebarsDotNet.HandlebarsEnvironment.CompileView(String templatePath) +101

The partial block expression works fine when the extra whitespace is removed. 🎉

{{#>myPartial}}
  Failover content
{{/myPartial}}

Back story: It's my first time using this library today - thank you, it's great!! I'm totally happy to contribute back a PR for this one, if you have any pointers on where to look? (I'm currently digging around the Lexer/Parser classes.)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions