Skip to content

Instantly share code, notes, and snippets.

@andreruffert
Created April 10, 2015 15:17
Show Gist options
  • Save andreruffert/eae466e184343f4f14a2 to your computer and use it in GitHub Desktop.
Save andreruffert/eae466e184343f4f14a2 to your computer and use it in GitHub Desktop.
Passing data to assemble partials
---
myPartial:
cssClass: myPartialCssClass
---
{{> partial myPartial}}
<div class="{{{cssClass}}}"></div>
@verpixelt
Copy link

Okay, that's cool but let's say I have to include the partial twice on the same page with different classes. How can I achieve that?

@andreruffert
Copy link
Author

Not sure if there is a better solution right now but this should work though.
I used it in a project some time ago...

page.html

{{#parseJSON '{"cssClass": "myPartialCssClass"}'}}
  {{> partial }}
{{/parseJSON}}

partial.html

<div class="{{{cssClass}}}"></div>

@verpixelt
Copy link

Thank you sooooo much @andreruffert!!!!!!

@andreruffert
Copy link
Author

👌 ✌️

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