StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET
Other
399 stars 58 forks source link

Custom default tags are not passed on to partials during rendering #103

Closed cconfer-livly closed 4 years ago

cconfer-livly commented 4 years ago

PartialTokenRenderer.cs [line 26] looks like it should be passing along the default tags to the parser. renderer.Render(context.RendererSettings.Parser.Parse(template, startingTags: context.RendererSettings.DefaultTags, lineIndent: obj.LineIndent), context); << or something of the sort

Not sure if this is by design or a bug.

In order to reproduce, use a variable in a partial template while rendering a template that references said partial template.

If you use the normal tags in the partial template ("{{", "}}") it renders the variable just fine.

Romanx commented 4 years ago

Hey @cconfer-livly,

This is actually a deliberate choice. It's not noted in the markdown spec although the spec tests are clear on this here.

The reason for this is immediately clear but if you think of them as external reusable pieces of templating then having them require the rendering contexts can cause things to suddenly not render as you expect. Using the default tags means that they're always parsed as defined in the template.

Hopefully this makes some sense, if you want a specific delimited to be parsed then you can use the set delimiter tag in your partial which should set it for that context.

Thanks for using Stubble!

cconfer-livly commented 4 years ago

thanks @Romanx !

appreciate the response.