drizzle icon indicating copy to clipboard operation
drizzle copied to clipboard

Adding arbitrary code samples to patterns

Open yodasw16 opened this issue 9 years ago • 2 comments
trafficstars

Is there a way to add arbitrary code samples to a pattern template? A few examples:

  • to show different markup than what is rendered above the markup sample
  • to show both the markup that renders the pattern and some additional markup that isn't rendered
  • to share the CSS for a pattern

yodasw16 avatar Sep 12 '16 14:09 yodasw16

@yodasw16 We have also experienced the need for this kind of flexibility.

Are you thinking that this would be a new property defined in the front-matter of a pattern with the arbitrary code provided as a fenced code block?

As a temporary workaround, you can always include code samples within the notes front-matter property (since it is parsed as Markdown), and use the sourceless flag to hide the default code sample. Example:

name: Button
sourceless: true
notes: |
  This is a button. Here is some code:
  ```html
  <button class="Button">Wooo</button>
  ```
  ```css
  .Button { }
  ```

Although you may need to add a little CSS to properly style the <pre> and/or <code> elements output by the Markdown engine.

erikjung avatar Sep 13 '16 19:09 erikjung

Yeah, I think it would have to either be a property in the front-matter or for things like showing css or js maybe having another file in the directory that get's pulled in to another <pre><code>. Not sure how that would work, but it would be useful.

yodasw16 avatar Oct 21 '16 20:10 yodasw16