-
Notifications
You must be signed in to change notification settings - Fork 30
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
Handlebars Partial blocks don't work for Patterns #87
Comments
That's interesting. This is definitely not by design, so we'll look into it. |
Can you confirm that every instance of the partial in question is being invoked using the block syntax ( If you need to use either the block syntax or <div class="MyComponent">
{{#if @partial-block}} {{! <-------- for using the block syntax }}
{{> @partial-block}}
{{else}}
{{#block "content"}} {{! <-------- for using embed or extend }}
Default content
{{/block}}
{{/if}}
</div> |
Sorry @erikjung I was out for the weekend. Yes I've used the block syntax. If you need to use either the block syntax or {{embed}} on a component partial, you can also try adding logic to check for @partial-block Do you mean if I want to use a template as embed AND partial? If so, no it is not my case. It seems that drizzle is just not looking at the |
I looked into this a bit further, and it appears you can use Here is an example that builds with no error: This is not intuitive, but it kind of makes sense. All patterns are registered as partials, and they are also rendered as patterns unless you put So if you intend to make a "base" pattern to be extended, there are two options for using the partial block syntax:
It's probably worth mentioning this in the docs :) |
@erikjung awesome man! Thank you so much for debugging this for me :) |
@erikjung the approach seems to be working, however it explodes when I use it as simple partial without the block syntax: ---
hidden: true
---
<div>
{{#if @partial-block}}
{{>@partial-block}}
{{else}}
Default Content
{{/if}}
</div> Works {{#>partial-name}}
{{/partial-name}} Doesn't work: {{>partial-name}} This should display the default content right? |
That should work fine. I added another example to this test branch to verify the plain partial usage, and I wasn't able to reproduce that error: https://github.com/cloudfour/drizzle/compare/debug-issue_87 Can you pull that branch and verify? |
Here is a diff of the part that cause the If I remove {{>"patterns.components.nav.item-link" href="#foo"}} the build doesn't break diff --git a/src/patterns/components/nav/example.hbs b/src/patterns/components/nav/example.hbs
new file mode 100644
index 0000000..7289bad
--- /dev/null
+++ b/src/patterns/components/nav/example.hbs
@@ -0,0 +1,14 @@
+{{#>patterns.components.nav.index}}
+
+ {{>"patterns.components.nav.item-link" href="#foo"}}
+
+ {{#>patterns.components.nav.item}}
+ {{#>patterns.components.nav.link href="#baz"}}
+ Link
+ <span class="SiteNav-wrapIcon">
+ <span class="Icon">🕶</span>
+ </span>
+ {{/patterns.components.nav.link}}
+ {{/patterns.components.nav.item}}
+
+{{/patterns.components.nav.index}}
diff --git a/src/patterns/components/nav/index.hbs b/src/patterns/components/nav/index.hbs
new file mode 100644
index 0000000..ed50b2c
--- /dev/null
+++ b/src/patterns/components/nav/index.hbs
@@ -0,0 +1,10 @@
+---
+hidden: true
+---
+<nav class="SiteNav" role="navigation">
+ {{#if @partial-block}}
+ {{>@partial-block}}
+ {{else}}
+ Nav List
+ {{/if}}
+</nav>
diff --git a/src/patterns/components/nav/item-link.hbs b/src/patterns/components/nav/item-link.hbs
new file mode 100644
index 0000000..a3ec35d
--- /dev/null
+++ b/src/patterns/components/nav/item-link.hbs
@@ -0,0 +1,12 @@
+---
+hidden: true
+---
+<span class="SiteNav-item">
+ <a class="SiteNav-link" href="{{href}}">
+ {{#if @partial-block}}
+ {{>@partial-block}}
+ {{else}}
+ Link
+ {{/if}}
+ </a>
+</span>
diff --git a/src/patterns/components/nav/item.hbs b/src/patterns/components/nav/item.hbs
new file mode 100644
index 0000000..ba6dc63
--- /dev/null
+++ b/src/patterns/components/nav/item.hbs
@@ -0,0 +1,10 @@
+---
+hidden: true
+---
+<span class="SiteNav-item">
+ {{#if @partial-block}}
+ {{>@partial-block}}
+ {{else}}
+ Item
+ {{/if}}
+</span>
diff --git a/src/patterns/components/nav/link.hbs b/src/patterns/components/nav/link.hbs
new file mode 100644
index 0000000..bbf8d23
--- /dev/null
+++ b/src/patterns/components/nav/link.hbs
@@ -0,0 +1,10 @@
+---
+hidden: true
+---
+<a class="SiteNav-link" href="{{href}}">
+ {{#if @partial-block}}
+ {{>@partial-block}}
+ {{else}}
+ Link
+ {{/if}}
+</a>
|
Thanks for the additional info. It looks like this is an issue that affects Handlebars itself: https://tonicdev.com/erikjung/57c72b19ad12611300cb9f58 ^ Same error conditions (no error when removing the |
@erikjung I see, thanks for taking the time to dig into this issue! [unrelated] I am working (hacking) on a fork of drizzle that integrates suitcss and what I think is a great (better) folders structure, I am also considering to make a template-engine agnostic builder pkg that uses consolidate.js or metalsmith-layouts behind the scenes – basically I may end up writing my own styleguide generator tool from scratch 😂 let me know if you folks are interested in a collaboration or want to discuss about this in details. |
@giuseppeg We use SUIT on most of our projects, so that's great 👍 The template handling is also something we plan on improving for 1.0. We've received some good feedback on it, and using Consolidate seems to make a lot of sense. |
That's how we ended up making Drizzle (forked Fabricator)! Our team welcomes contributions and collaborations. If you have ideas, proposals or wish to discuss some aspect of the hack/fork/project you're working on to see if your ideas would be a good fit for Drizzle proper, please don't hesitate to create issues or ping any of us! |
Hi there,
do handlebars partial blocks work only for the styleguide templates or can I use them in Pattern templates as well?
I could use
embed
butpartial-blocks
are neat.Here's what I am trying to do:
In
patterns/components/MyComponent/index.hbs
:Somewhere else:
Expected result:
Instead I get an error
The text was updated successfully, but these errors were encountered: