fbrctr / fabricator

A tool for building website UI toolkits and style guides
http://fbrctr.github.io/
MIT License
1.11k stars 124 forks source link

materials helper doesn't receive context & opts #238

Closed davidmondok closed 8 years ago

davidmondok commented 8 years ago

I want to dynamically include materials based on a variable. I use the materials helper as follow


---
partial: foo

---
{{materials materialname.partial}} // there's a foo.html in my materials folder

The assembly task throws me an error though in the materials helper function, because it's not passed a context and opts, and therefore opts.hash is undefined:

return beautifyHtml(fn(buildContext(context, opts.hash)).replace(/^\s+/, ''), options.beautifier);

Do I have to pass the context and opts myself, and if yes, how can I reference them from a partial? If no, I guess these should be passed in by default?

thx for the help

LukeAskew commented 8 years ago

The helper is actually {{material}} without the s at the end. That might be what's causing the error.

davidmondok commented 8 years ago

@LukeAskew I did actually use only material in my code, I only messed up in my comment. So unfortunately that's not causing the error

LukeAskew commented 8 years ago

Ah. I think I understand now. Looks like there is a bit of a bug in the assembler but you can still get it to work.

{{{material materialname.partial @root}}}

The material helper expects an additional parameter of "context".