cloudfour / fabricator

A tool for building website UI toolkits
http://fbrctr.github.io/
1 stars 0 forks source link

Materials appear to ignore custom front-matter properties in Fabricator partials #18

Closed tylersticka closed 9 years ago

tylersticka commented 9 years ago

Hoping @lyzadanger or @erikjung can help with this one, because I'm apparently not smart enough to figure it out on my own!

As of #17 being merged, there's a placeholder style for external documentation links, which can be really useful when passing along patterns that borrow from some standard or existing body of work:

screen shot 2015-05-07 at 5 10 40 pm

My intention was to allow for documentation links to be passed along similar to other attributes like notes:


---
notes: |
  These are notes associated with this `button` component.
see:
  SUITCSS Documentation: https://github.com/suitcss/components-button/
  MDN Documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button

---
<button class="button">Submit</button>

But after much banging my head against the wall, I discovered that, for whatever reason, I can't get materials to output any custom YAML properties. Even this:


---
foo: 'bar'

---
<p>foo {{ foo }}</p>

Will compile to:

<p>foo </p>

I whipped up a quick JSON.stringify helper for Handlebars, and none of my custom properties are actually making it to the template.

Help? :helicopter:

Update: The simplified examples above do not reflect that this is impacting Fabricator partials specifically. Please read the whole thread for an elaborated description of the issue.

erikjung commented 9 years ago

Looking at what's happening in Fabricator Assemble, it appears that any custom front-matter is available at {{material-name.field}}, so in this case you would use:

{{button.foo}}

EDIT: though looking at the test fixtures, it seems like the namespace shouldn't be required.

Example: https://github.com/fbrctr/fabricator-assemble/blob/master/test/fixtures/materials/components/alerts/primary.html

lyzadanger commented 9 years ago

My guess is that @erikjung 's comment gives some meat to the matter but I'm happy to help if it doesn't get you all the way, @tylersticka

tylersticka commented 9 years ago

@lyzadanger @erikjung That example (as well as the material name) is useful when you're in an actual material template, but it's less useful when you're in a Fabricator partial, in this case f-item-content.html. That's the context I can't find documented, and it's essential to being able to implement new features without hacking fabricator-assemble.

So, I'm still stumped.

lyzadanger commented 9 years ago

@tylersticka I'll take this one!

tylersticka commented 9 years ago

Thank you!

erikjung commented 9 years ago

@tylersticka As a temporary workaround, you can try {{@root.button.foo}}, if you need to develop something and don't mind seeing the button specific data showing up on every material.

tylersticka commented 9 years ago

@erikjung Thanks, but I think I'll just hold off for now. The hard part (the styles and markup) is done, wiring it in should be trivial. I'd rather just postpone the task for now.

erikjung commented 9 years ago

We created an issue for this in the Fabricator Assemble repo. https://github.com/fbrctr/fabricator-assemble/issues/9

tylersticka commented 9 years ago

Thanks, guys!

tylersticka commented 9 years ago

I have confirmed that this is working as of #22 being merged. :+1: