Skip to content

Instantly share code, notes, and snippets.

@backlineint
Created July 22, 2019 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save backlineint/6b6e2b016b98f956e78b548be4515e5a to your computer and use it in GitHub Desktop.
Save backlineint/6b6e2b016b98f956e78b548be4515e5a to your computer and use it in GitHub Desktop.
Twig In React Storybook
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';
import template from './TestTwig.twig';
import chip from '~../../../twig-assets/e-chip.twig';
const templateTwig = (
chip({
description: 'Description',
designer: 'Designer',
price: '$400'
})
)
storiesOf('Core', module).add(
'Test Twig',
() => (
<div dangerouslySetInnerHTML={{__html: templateTwig}}></div>
),
{ notes }
);
// in .storybook directory
// Export a function. Accept the base config as the only param.
module.exports = async ({ config, mode }) => {
// `mode` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.
// Make whatever fine-grained changes you need
config.module.rules.push({
test: /\.twig$/,
loader: "twig-loader",
options: {
// See options section below
},
});
// Return the altered config
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment