emiloberg / markdown-styleguide-generator

Will search all your (s)css files for comments and generate a single page html styleguide
GNU General Public License v3.0
62 stars 19 forks source link

Custom handlebars variables #4

Closed Cleecanth closed 9 years ago

Cleecanth commented 9 years ago

First, I just want to thank you. This is exactly what I was looking for (and came unbelievably close to trying to create on my own). So, thank you for this — you've saved me numerous hours and answered like 30 of my prayers.

That said, it would be nice to be able to define custom handlebars variables within the .styleguide file for use within the template.html.

As a very simple example, within the .styleguide, if you could do something like:

{
  //...config stuff
  "customVars": {
    "externalJs": "/my/script.js",
    "pageTitle" : "My Project Style Guide"
  }
}

and in template.html:

<title>{{customVars.pageTitle}}</title>
{{#if customVars.externalJS}}
  <script src="{{customVars.externalJs}}">
{{/if}}

You could obviously do a whole lot more. But the general idea is that you'd be making your template more portable (for use across projects).

emiloberg commented 9 years ago

Done! Just pushed version 2.0.4

Update the tool and add your custom variables in your .styleguide file like:

customVars: {
    sampleVar: 'Hello from customVars!'
},

and then request them from the handlebars template

{{customVars/sampleVar}}

(any new project you styleguide init in will have a sample variable set in the .styleguide file)

Works?

Cleecanth commented 9 years ago

Yep, that works for me. Thanks, man.