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

Support for handlebars partials #23

Closed
dscottboggs opened this issue Apr 14, 2021 · 3 comments
Closed

Support for handlebars partials #23

dscottboggs opened this issue Apr 14, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@dscottboggs
Copy link

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 💯

@mufeedvh
Copy link
Owner

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! 🙌❤️

@mufeedvh mufeedvh added the enhancement New feature or request label Apr 16, 2021
@dscottboggs
Copy link
Author

Sweet, I'll try to work on adding that if I get the chance.

@mufeedvh
Copy link
Owner

This feature has been implemented!

v0.2.0 Released! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants