Skip to content

@partial-block not working as partial block or as conditional #519

Closed

Description

@stellR42

Describe the bug

I'm trying to register a partial that can either be used as a block, with block content, or inline without content. However, both methods I tried using to accomplish this aren't working because @partial-block doesn't seem to be properly recognized. The only way I can get @partial-block to render is by using {{> @partial-block}} on it's own. Both of the following cases don't render anything:

Block:

{{#> @partial-block }}
{{/@partial-block}}

Conditional:

 {{#if @partial-block}}
  {{> @partial-block}}
  {{/if}}

Expected behavior:

@partial-block should be recognized in both the above scenarios and render the block content if it is provided.

Test to reproduce

[Fact]
public void Descriptive_Test_Name_Here()
{
      var template = @"
{{#> myPartial}}
Block content
{{/myPartial}}";
            var partial =
                @"  
Conditional:
  {{#if @partial-block}}
  {{> @partial-block}}
  {{/if}}
Plain:
  {{> @partial-block}}
Block:
{{#> @partial-block }}
{{/@partial-block}}";
            var handlebars = Handlebars.Create();
            handlebars.RegisterTemplate("myPartial", partial);
            var render = handlebars.Compile(template);
            object data = new { };
            var actual = render(data);
            Assert.Equal("Conditional: Block content Plain: Block content Block: Block content", actual);
}

Activity

  1. oformaniuk commented on Apr 27, 2022

    @oformaniuk
    Member

    The problem is in the implementation of @partial-block itself. Right now it is not implemented as a property of the context.
    I see couple ways to fix it:

    • Add virtual property @partial-block to the context and evaluate it according to whether block is set on the context;
    • Rewrite current implementation and implement it as actual context @ property.
  2. added 2 commits that reference this issue on Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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