straker / livingcss

Parse comments in your CSS to generate a living style guide using Markdown, Handlebars, Polymer, and Prism syntax highlighter.
MIT License
241 stars 21 forks source link

Tags work #32

Closed kriss145 closed 7 years ago

kriss145 commented 7 years ago

Hi,

How we can use tags in our styleguide? In documentation we have examples how generating but I don't see example how to use.

Could you help?

straker commented 7 years ago

Sorry for the late response, I was at a conference all week.

If I understand the question correctly, you want to know how to use a tag in the handlebars markup that generates the style guide. Is that correct?

If so, let's say your comment looks like this:

/**
 * A simple Button.
 * @section Buttons
 * @example <button>Click Me</button>
 * @customTag Hello World
 */

This would generate a context object like so:

{
  "sections": [{
    "name": "Buttons",
    "description": "<p>A simple Button.</p>",
    "example": {
      "description": "<button>Click me</button>",
      "type": "markup"
    },
    "customTag": "Hello World"
  }]
}

Then in handlebars you would do this:

{{#each sections}}
  <h1>{{name}}</h1>
  {{{description}}}
  <div>{{{example.description}}}</div>
  <div>{{customTag}}</div>
{{/each}}
kriss145 commented 7 years ago

@straker Thanks! Now I know everything.

straker commented 7 years ago

Awesome. I'll go ahead and add this to the README later tonight so ti's more readily available.