Skip to content

Unable to render Partial HandelBarReuntimeException #545

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

varhandlebars=Handlebars.Create();handlebars.Configuration.UseJson();stringemail_skeleton=File.ReadAllText($"{AppContext.BaseDirectory}/templates/EmailSkeleton.html");Handlebars.RegisterTemplate("content",content);vartemplate=handlebars.Compile(email_skeleton);stringtemp=template(objects);returntemp;

email_skeleton

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

content

<divstyle="padding-bottom: 30px"><span>Dear {{user.name}}</span></div><divstyle="padding-bottom:30px"><span>The following Objective {{obj.objective_name}} has been createed</span></div><divstyle="padding-bottom:30px"><span>You Can View the Created Objective in the following Link:</span></div><divstyle="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
<tablealign="center" border="0" cellpadding="0" cellspacing="0" width="100%"
style="border-collapse:collapse;margin:0 auto; padding:0; max-width:600px"><tbody><tr><tdalign="center" valign="center" style="text-align:center; padding: 40px"><ahref="http://methodcorp.com" rel="noopener" target="_blank"><imgalt="Logo"
src="http://methodcorp.com/wp-content/uploads/2021/04/Method_logo_sticky-300x87-1.png?x76110" /></a></td></tr><tr><tdalign="left" valign="center"></td></tr><tr><tdalign="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

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