0.0.12 • Published 7 years ago

template-code-gen v0.0.12

Weekly downloads
2
License
MIT
Repository
github
Last release
7 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

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago