Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statiq.Web with Handlebars: How to Render Partials Correctly #1023

Open
mjehle82 opened this issue Oct 30, 2024 · 0 comments
Open

Statiq.Web with Handlebars: How to Render Partials Correctly #1023

mjehle82 opened this issue Oct 30, 2024 · 0 comments

Comments

@mjehle82
Copy link

I am using the Statiq.Web NuGet package to render handlebar templates into a static website.

While I like the idea of Statiq a lot, there is little to no documentation on how to actually use it.

My Statiq pipeline currently looks as follows.

await Bootstrapper
    .Factory
    .CreateDefault(args)
   
    .BuildPipeline("Render home", builder => builder
        .WithInputReadFiles("home.hbs", "Partials/*.hbs")
        .WithProcessModules(
            new RenderHandlebars()
                .WithModel(new MyModel())
                .WithPartial("head", Config.FromContext(c => c.Inputs.First(i => i.Source.Name == "head.hbs").ContentProvider.GetTextReader().ReadToEnd())))
        .WithOutputWriteFiles(".html"))
    
    .RunAsync();

This does work and all the Handlebars features (placeholders and partials) are rendered correctly.

However, it does not feel 100% clean to read the content of the partial with: .ContentProvider.GetTextReader().ReadToEnd()

Is there a way to do this more elegantly?

@github-staff github-staff deleted a comment from mjehle82 Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant