Templates
Create templates for common abstractions and leverage SKAT's power of automation to generate boilerplate code. This will increase your team's productivity, help you enforce your standards and help on-board new team members.
#
Filenames & GroupingThere is no real requirement for file names, so you can get creative and use the tool however it yields more value to
you and your team, however, a useful pattern to keep in mind could be would be to start the name with the abstraction
layer
followed by "group names". For example component.view.js
. This would allow you to group many templates under with
the component
prefix but if you only want the view you can be more specific and use component.view
.
#
Grouping Examples#
Pure Component GroupIn our projects, to create a React component, we separate the view, types and stories into separate files and put it all together before exporting it in an index.js file. We can group our templates like so:
Run skat gen -w pure -n ComponentName
to use the template group.
#
Redux Reducer GroupRedux Reducer must have a reducer file, a type file and an action file. For this we can group our templates like so:
Run skat gen -w reducer -n ReducerName
to use the template group.
#
SubstitutionsTemplates can have variables which will be substituted when copying the template. Simply put a name between dollar
signs. For example function $NAME$() {
and pass in the substitution in the CLI with the -s or --substitute
command.
The value for the substitute cli argument is a key:value
pairs separated by ,
.
This command will substitute $NAME$
for MySection and $TITLE
for "This is my Section".