# Supporting Other Component Types

There is a requirement to support other technology stacks as well as React, so the toolbelt has been enhanced to support this in the following ways.

## Creating Components

The `init` command defaults to creating a React-based component, however it is also possible to create a [Handlebars](http://handlebarsjs.com) or [Typescript](https://www.typescriptlang.org) based component by passing in `handlebars` or `typescript` as an additional argument to the `blackjack init` command (e.g. `blackjack init my-awesome-component handlebars`).

If specified as an argument, a sub-command from `src/commands/init.js` is fired to `src/commands/init/{TYPE}.js` which then handles the request and creates a new component that is relevant to the specified command. This is handled by the `templateMap` which maps the template file (the right-hand `.tpl`) to the actual file that should be created, creating the directory structure to support the component structure and creating the file from the template with the variables replaced.

```
const templateMap = {
    'src/index.js': 'react/index.js.tpl',
    'src/preview.js': 'react/preview.js.tpl',
    'src/components/${name}.js': 'react/component.js.tpl',
    'styles/components/${name}.scss': 'common/styles.scss.tpl',
    'test/components/${name}.test.js': 'common/test.js.tpl',
    '.gitignore': 'common/gitignore.tpl',
    'package.json': 'react/package.json.tpl',
    'readme.md': 'common/readme.md.tpl',
};
```

## Previewing Components

Non-React based components have package files that specify the type of technology being used, so the `blackjack.type` variable is used by the toolbelt to indicate how the component should be previewed. In the example below this is set to `handlebars` so that when `blackjack preview` is run against this component, [Handlebars](http://handlebarsjs.com) is used to preview the component rather than React.

```
"blackjack": {
    "type": "handlebars",
    "preview": "src/preview.js",
    "index": "src/index.js",
    "handlebars": {
        "data": "sample/data.json",
        "helpers": "src/helpers.js",
        "template": "template.hbs"
    }
}
```

It's worth noting in the above example that other variables are also set to inform Handlebars where to look for the sample data json file and any helpers that the component may need.

### Static CSS
A reference to the [SASS](http://sass-lang.com) file is also specified so the component can be preview static without the need for javascript, bypassing webpack using the `blackjack preview static` command.

```
"blackjack": {
    "type": "handlebars",
    "css": {
        "main": "styles/components/${name}.scss"
    }
}
```

## Testing Components

Non-React Components can be tested using the same `blackjack test` command which will test any Javascript files in your component.

## Linting Components

Non-React Components can be linted using the same `blackjack lint` command which will lint any Javascript and/or SASS files in your component.
