react-markdown-loader icon indicating copy to clipboard operation
react-markdown-loader copied to clipboard

Options to change the code template

Open mrbinky3000 opened this issue 7 years ago • 6 comments

Thanks for creating this. It's almost exactly what I was looking for.

How do you pass your own custom template to wrap the rendered tag and the html source?

mrbinky3000 avatar Jan 10 '17 21:01 mrbinky3000

Can you give me an example of what you want to achieve?

javiercf avatar Jan 16 '17 21:01 javiercf

@javiercf In many situations I find that the demo code needs to be more complicated than the codeblock. It would be nice to have some control over the way the block is handled.

lukaswelinder avatar Jan 21 '17 22:01 lukaswelinder

Simply allow us to set the template as a string of HTML. Your current template shows us the formatted code, and inserts the rendered Component. It would be nice if those two things could be replaced by placeholders in our template string. For example <div>{{code}}</div><div>{{component}}</div>

mrbinky3000 avatar Jan 23 '17 18:01 mrbinky3000

I'm using handlebars above, but use any method you like.

mrbinky3000 avatar Jan 23 '17 18:01 mrbinky3000

@mrbinky3000 I was thinking something more along the lines of convention on the language/render declaration:

// Render component only:
~~~ render
<Component { ...props } />
~~~
// Render with code block:
~~~ render jsx
<Component { ...props } />
~~~

However I do like the idea of being able to decide where the component is rendered:

~~~ render(componentName) jsx
<Component { ...props } />
~~~

... some README stuff
{ componentName.codeblock }
... more README stuff
{ componentName.component }

Or something along those lines...

lukaswelinder avatar Jan 24 '17 05:01 lukaswelinder

I think if we support a custom template for the code source and executed, we'll need to add an option in the loader that would go into the webpack config.

fernandopasik avatar May 09 '17 04:05 fernandopasik