Git Product home page Git Product logo

Comments (10)

jonschlinkert avatar jonschlinkert commented on August 15, 2024

Gist: https://gist.github.com/jonschlinkert/5552311

from handlebars-helpers.

doowb avatar doowb commented on August 15, 2024

We've added nested layouts in assemble, but those don't address the specific issue that was created.

Here's an example of what we can use for this.

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

let's do it a little differently, maybe use the options hash to determine the block type instead of duplicating the same code three times and only changing a property.

from handlebars-helpers.

AndersDJohnson avatar AndersDJohnson commented on August 15, 2024

+1

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

I was thinking about this, and technically shouldn't it be possible to actually register a partial with a helper? Meaning that you could have a block helper that does something like this:

Handlebars.registerHelper("partial", function(name, options) {
  Handlebars.registerPartial(name, options.fn);
});

and then in templates:

{{#partial "head"}}
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
{{/partial}}

{{#partial "footer"}}
<script src="{{assets}}/js/jquery.js"></script>
<script src="{{assets}}/js/bootstrap.min.js"></script>
{{/partial}}

This doesn't work currently, or at least it didn't when I tried it - perhaps due to how/when partials are registered? But it seems like this would allow us to resolve this issue.

from handlebars-helpers.

doowb avatar doowb commented on August 15, 2024

See my PR #75 and let me know if this is what you're thinking. I can add the content option in the morning and we can merge it then.

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

by "content option" I'm assuming you mean a hash for content placement? like append, prepend etc.? if so, yeah that's really nice. Maybe something like this?:

{{#content "append" "footer"}}
  This will be appended.
{{/content}}

{{#content "prepend" "footer"}}
  This will be prepended to the "foot" block
{{/content}}

{{#content "replace" "header"}}
  This will replace the "header" block
{{/content}}

or even better:

{{#content append="footer"}}
  This will be appended.
{{/content}}

{{#content prepend="footer"}}
  This will be prepended to the "foot" block
{{/content}}

{{#content replace="header"}}
  This will replace the "header" block
{{/content}}

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

obviously we could make the hashes more verbose, but I guess that's 6 to one half dozen to the other e.g.:

{{#content "footer" block"append"}}
  This will be appended.
{{/content}}

{{#content "footer" block"prepend"}}
  This will be prepended to the "foot" block
{{/content}}

{{#content "header" block"replace"}}
  This will replace the "header" block
{{/content}}

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

@doowb ooh I can use this on the component stuff I started today...

from handlebars-helpers.

jonschlinkert avatar jonschlinkert commented on August 15, 2024

resolved :-) thanks @doowb

from handlebars-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.