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

Feature suggestions #7

Open
Extarys opened this issue Aug 27, 2017 · 2 comments
Open

Feature suggestions #7

Extarys opened this issue Aug 27, 2017 · 2 comments

Comments

@Extarys
Copy link

Extarys commented Aug 27, 2017

I never had to implement this, but is it possible to do something like this:

layout.hbs:

<body>
   {{{body}}}
   {{>foot}}
</body>

index.hbs:

{{#> more-script}}
   <script>//tada!</script>
{{/more-scripts}}

foot.hbs

{{#> more-script}}
   {{!-- per page script --}}
{{/more-scripts}}

I notice many packages have a block, contentFor, or extends block on npm but lack the layout feature crying
No idea how I can do this. Some quick syntax on the top of my head I read earlier.

Page 1:

<div>
   {{#block 'myname"}}{{/block}}
</div>

Other page:

{{contentFor "myname"}}
   Oh my gosh!
{{/contentFor}}

By extend:

Page 1:

<div>
   {{#block 'myname"}}{{/block}}
</div>

Other page:

{{#extend "page1"}}
{{#block "myname"}}
   Oh my gosh!
{{/block}}
@Extarys
Copy link
Author

Extarys commented Aug 27, 2017

Nevermind, https://cloudfour.com/thinks/the-hidden-power-of-handlebars-partials/ solve the need for any packages - I think

@ConnorWiseman
Copy link
Owner

Your question seems more about how Handlebars itself really works. This package doesn't really do much except re-introduce the layouts feature. As of 1.0.0 (~a few minutes ago), however, you can pass your own instance of a Handlebars environment in and register your own block helpers/partials/whichever with that ahead of time, if that suits your needs.

I'd be interested in learning more about the items you've mentioned, though. Are those external functionality provided by other packages, or some sort of helper functions? I'm not familiar enough with the concepts in your example to know at a glance. Can you list any packages on npm that include this functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants