tnguyen14 / wintersmith-handlebars

handlebars plugin for wintersmith
26 stars 11 forks source link

adding handlebars template inheritance #2

Closed samharnack closed 11 years ago

tnguyen14 commented 11 years ago

About your layout and index templates - correct me if I'm wrong, but it seems like you are trying to change the Handlebars template to fit the scheme of the original jade template. Originally I had a different idea of how Handlebars template should work. It is not based on a main layout with customizable components. It is more like a bunch of smaller components that could be used in different templates.

tnguyen14 commented 11 years ago

Could you also provide a use case and example for "template inheritance"?

samharnack commented 11 years ago

It's more about supporting nested templates and not having to use partials as headers and footers. I think for larger sites that could become a maintenance nightmare. Using partials is still there as its part or handlebars itself. See here for an example and also where the code was derived from: http://thejohnfreeman.com/blog/2012/03/23/template-inheritance-for-handlebars.html

tnguyen14 commented 11 years ago

Thanks for the link. Yeah I see what you're trying to do. However, I'm still not convinced how that could be problematic in a larger site. In my opinion, an inheritance system like what you're describing makes it much harder to customize because templates are based off of 1 general template. In a large site with many different templates, inheritance defeats the purpose because you end up writing more templates.

A modularized components approach (the inclusion approach mentioned in the article) is in my opinion more effective in being used across very different templates, thus increase code reuse.

samharnack commented 11 years ago

This pull request doesn't change the ability to do that. It just adds the ability to nest templates.

tnguyen14 commented 11 years ago

A couple things:

  1. This pull request not just modify the main plugin file but also the example and layout files. Could you separate them? It would be cleaner to have a pull request with just the changes for the plugin file.
  2. The changes in the layout files could be pulled out as a separate example of how inheritance could be used for template. This way it could be made clear that both the components approach or the inheritance approach are available.
  3. Could you also write some documentation to be included in README for how inheritance can be used? For example, how to use the partial and block helper, because I don't think those are very clear.

Thanks.

samharnack commented 11 years ago

This PR is a little premature. There is an issue with nesting templates and scoping of partials. Once I get it ironed out I will submit another PR with more examples and answers to your questions.

tnguyen14 commented 11 years ago

Okay thanks. Submit another PR and I will merge it in. I like the idea that this allows for using inheritance template without breaking the original template idea.