drizzle
drizzle copied to clipboard
Adding arbitrary code samples to patterns
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 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.
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.