Support for handlebars partials
dscottboggs opened this issue ยท 3 comments
It would be great if we could define partials and reference them in our templates. Ideally, I'd like to define a single layout template with a content block which could be filled in by a number of other templates.
I'd be happy to implement this if that would help, but I would like some guidance on how you'd like it integrated if I were to create a PR.
Thanks for the awesome project BTW ๐ฏ
Hey @dscottboggs,
I've also encountered situations where I thought this feature would really help. I am currently working on the next version in my spare time and I've been planning for ways to make use of handlebars
to use it's more features, current version only handles variables which is why I kept it as .html
files and the next one handles them all purely as .hbs
files. I think this feature is the first one I should implement so I will track it using this issue itself and work on it.
And you are more than welcome to create a PR and work on this. ๐
Here is how I am planning to implement this:
Templates are rendered on initialization and along with writing the template_variables
, we can register a main template
. After that, write the contents from template variables (if those are used) and as writing long content in the JSON value is not clean, I am thinking of sub-templates in the config file which will be used as the content to be rendered, like this:
...
"partials": {
"seo-tags": "seo-tags.hbs",
"nav-bar": "nav-bar.hbs",
}
...
Reference: handlebars-rust
Partials Example
NOTE: If you have ideas for a better implementation, please feel free to suggest them. ๐
And I am glad you liked the project, thank you! ๐โค๏ธ
Sweet, I'll try to work on adding that if I get the chance.
This feature has been implemented!
v0.2.0 Released! ๐