code generate from your template file.
template
import React from "react";
import PropTypes from "prop-types";
import BEMHelper from "react-bem-helper";
import "./{{=it.name.pascalCase}}.css";
const {{=it.name.pascalCase}} = ({ {{=it.props.toString()}} }) => {
const classes = new BEMHelper({
name: "{{=it.name.paramCase}}",
prefix: "{{=it.prefix}}-"
});
return (
<div {...classes()}>
</div>
);
};
{{=it.name.pascalCase}}.propTypes = {
{{~it.props :value:index}}
{{=value}}: PropTypes.any,
{{~}}
};
export default {{=it.name.pascalCase}};
command
template-code-gen test stateless -d ./atoms --props message,button --prefix a
outputfile
import React from "react";
import PropTypes from "prop-types";
import BEMHelper from "react-bem-helper";
import "./Test.css";
const Test = ({ message,button }) => {
const classes = new BEMHelper({
name: "test",
prefix: "a-"
});
return (
<div {...classes()}>
</div>
);
};
Test.propTypes = {
message: PropTypes.any,
button: PropTypes.any,
};
export default Test;
npm i template-code-gen -D
template-code-gen name templatePath
react props
prefix
output directory path
output directory name
If you want to specify a name, write name.pascalCase or name.paramCase.
"tcg": {
"templates": "./templates/"
},
ref doT
{{=it.name.paramCase}}
coffeeCup > coffee-cup
{{=it.name.pascalCase}}
test-case > TestCase
prefix value
{{=it.prefix}}
props value
{{it.props :value:index}} {{=value}} {{}}