Handlebars-Net/Handlebars.Net

Unable to render Partial HandelBarReuntimeException

fshahin90 opened this issue · 0 comments

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