zigzap / zap

blazingly fast backends in zig
MIT License
1.99k stars 71 forks source link

Add MustacheLoad to support loading from file #42

Closed sadbeast closed 9 months ago

sadbeast commented 9 months ago

According to the facil.io docs (http://facil.io/0.7.x/fiobj_mustache#fiobj_mustache_new):

By setting the filename argument even when the data argument exists, it will allow path resolution for partial templates. Otherwise, there is no way to know where to find the partial templates.

This will allow partial templates to work.

However, this also introduces a breaking change to the existing MustacheNew function. This change makes it mirror the C version more closely where it accepts a MustacheLoadArgs struct instead of just the data. Although that's also a handy method to have, so I renamed that to MustacheData...maybe there's a better name?

renerocksai commented 9 months ago

FYI I have applied your patch locally, and will add above suggestions before pushing. Thanks a lot, this is a great addition for Mustache users.

renerocksai commented 9 months ago

Thanks a lot for this PR :pray: , I merged it locally, applied my suggestions, and created a new release!!!

renerocksai commented 9 months ago

BTW of course, your commit 8f5aa17109dbb0b6168b9cf1b0c4e78c5a6d95b1 is preserved in git history, in case you are wondering.

sadbeast commented 9 months ago

Fantastic, thanks so much! I agree with the separate MustacheLoadArgs approach, much cleaner.