Skip to content

Unable to render Partial HandelBarReuntimeException #545

Closed

Description

@fshahin90

Trying to Register a Partial Using Handlebars.RegisterTemplate("content",content); and getting the error HandlebarsDotNet.HandlebarsRuntimeException: Referenced partial name content could not be resolved

My Code

var handlebars = Handlebars.Create();
            handlebars.Configuration.UseJson();

            string email_skeleton = File.ReadAllText($"{AppContext.BaseDirectory}/templates/EmailSkeleton.html");
            
            
            Handlebars.RegisterTemplate("content",content);

            var template = handlebars.Compile(email_skeleton);

            string temp = template(objects);

            return temp;

email_skeleton

 <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"
            style="border-collapse:collapse;margin:0 auto; padding:0; max-width:600px">
            <tbody>
                <tr>
                    <td align="center" valign="center" style="text-align:center; padding: 40px">
                        <a href="http://methodcorp.com" rel="noopener" target="_blank">
                            <img alt="Logo"
                                src="http://methodcorp.com/wp-content/uploads/2021/04/Method_logo_sticky-300x87-1.png?x76110" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="center">
                        {{> content}}
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="center"
                        style="font-size: 13px; text-align:center;padding: 20px; color: #6d6e7c;">
                        <p></p>
                    </td>
                </tr>
            </tbody>
        </table>

content

<div style="padding-bottom: 30px"><span>Dear {{user.name}}</span></div> <div style="padding-bottom:30px"><span>The following Objective {{obj.objective_name}} has been createed</span></div> <div style="padding-bottom:30px"><span>You Can View the Created Objective in the following Link:</span></div> <div style="padding-bottom: 40px; text-align:center;"></div>

Stuff I tried

  1. added the partial inside a block {{#test}}{{/test}} resulted in a empty content and added test as an object
 <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"
            style="border-collapse:collapse;margin:0 auto; padding:0; max-width:600px">
            <tbody>
                <tr>
                    <td align="center" valign="center" style="text-align:center; padding: 40px">
                        <a href="http://methodcorp.com" rel="noopener" target="_blank">
                            <img alt="Logo"
                                src="http://methodcorp.com/wp-content/uploads/2021/04/Method_logo_sticky-300x87-1.png?x76110" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="center">
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="center"
                        style="font-size: 13px; text-align:center;padding: 20px; color: #6d6e7c;">
                        <p></p>
                    </td>
                </tr>
            </tbody>
        </table>
  1. Ive read in the issues about the partial block {{#>content}}ites empty{{/content}} but this didnt work either it failes to the content inside the block

Activity

  1. TheConstructor commented on Oct 17, 2025

    @TheConstructor
    Contributor

    This works after you replace Handlebars.RegisterTemplate("content",content) by handlebars.RegisterTemplate("content",content). As an alternative, you could skip creation of handlebars and call Handlebars.Compile(email_skeleton) instead.

  2. added a commit that references 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

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions