0.0.12 • Published 6 years ago

template-code-gen v0.0.12

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

template-code-gen

Build Status npm version

code generate from your template file.

example

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;

install

npm i template-code-gen -D

usage

template-code-gen name templatePath

command option

props (csv)

react props

prefix (string)

prefix

dest (string)

output directory path

destDirName (string)

output directory name

If you want to specify a name, write name.pascalCase or name.paramCase.

package.json

root template path

  "tcg": {
    "templates": "./templates/"
  },

template syntax

ref doT

Built-in variables

paramCase name

{{=it.name.paramCase}}

coffeeCup > coffee-cup

pascalCase name

{{=it.name.pascalCase}}

test-case > TestCase

prefix

prefix value

{{=it.prefix}}

props(array)

props value

{{~it.props :value:index}} {{=value}} {{~}}

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago