Template Context
Name
{{= tps.name }}
Name of new instance you are rendering. When rendering two or more instances at the same time. The same concept as above apply's but for each path you pass in.
If you generate a new instance of a template with no build path. Then tps.name
will be null.
Example
cli
tps react-component Nav
Dot Template
const {{= tps.name}} = (props) => {
return (
<div></div>
)
}
Result
null
Template
{{= tps.template }}
Name of the template your rendering with.
Example
cli
tps express-app app
|__________|
# ^ This is the name of the template
Packages
{{= tps.packages }}
List of packages that were used when rendering your template.
tip
Remember default
package is include by default
When no additional packages are used:
["default"]
when additional packages are used:
["default", "css", "unit-tests"]
Example
- Additional packages
- No additional packages
cli
tps react-component App --packages css
Dot Template
import React from react;
{{{? tps.packages.includes("css")}}}
import "{{= tps.name}}.css";
{{{?}}}
const {{= tps.name}} = (props) => {
return (
<div></div>
)
}
Result
null
cli
tps react-component App
Dot Template
import React from react;
{{{? tps.packages.includes("css")}}}
import "{{= tps.name}}.css";
{{{?}}}
const {{= tps.name}} = (props) => {
return (
<div></div>
)
}
Result
null
Answers
Type
{ [p: string]: any }
Usage
{{= tps.answers }}
Alias
{{= tps.a }}
The tps.answers
object holds the answers to the prompts in your templates.
Each prompt's value is stored with a property name that corresponds to the name
you assigned to the prompt in your settings.json
file.
Example
settings.json
{
"prompts": [
{
"name": "age"
// ...
}
]
}
you can access the users answer with:
{{= tps.answers.age }}
utils
Type
{ [p: string]: () => any }
Usage
{{= tps.utils }}
Alias
{{= tps.u }}
camelCase
Usage
{{= tps.utils.camelCase(str) }}
Example
Live Editor
() => tps.utils.camelCase("example text")
Result
Loading...
capitalCase
Usage
{{= tps.utils.capitalCase(str) }}
Example
Live Editor
() => tps.utils.capitalCase("example text")
Result
Loading...
constantCase
Usage
{{= tps.utils.constantCase(str) }}
Example
Live Editor
() => tps.utils.constantCase("example text")
Result
Loading...
dotCase
Usage
{{= tps.utils.dotCase(str) }}
Example
Live Editor
() => tps.utils.dotCase("example text")
Result
Loading...
headerCase
Usage
{{= tps.utils.headerCase(str) }}
Example
Live Editor
() => tps.utils.headerCase("example text")
Result
Loading...
noCase
Usage
{{= tps.utils.noCase(str) }}
Example
Live Editor
() => tps.utils.noCase("example text")
Result
Loading...
paramCase
Usage
{{= tps.utils.paramCase(str) }}
Example
Live Editor
() => tps.utils.paramCase("example text")
Result
Loading...
pascalCase
Usage
{{= tps.utils.pascalCase(str) }}
Example
Live Editor
() => tps.utils.pascalCase("example text")
Result
Loading...
pathCase
Usage
{{= tps.utils.pathCase(str) }}
Example
Live Editor
() => tps.utils.pathCase("example text")
Result
Loading...
sentenceCase
Usage
{{= tps.utils.sentenceCase(str) }}
Example
Live Editor
() => tps.utils.sentenceCase("example text")
Result
Loading...
snakeCase
Usage
{{= tps.utils.snakeCase(str) }}
Example
Live Editor
() => tps.utils.snakeCase("example text")
Result
Loading...
pluralize
Usage
{{= tps.utils.pluralize(str, plural) }}
Example
Live Editor
() => tps.utils.pluralize("example")
Result
Loading...
singularize
Usage
{{= tps.utils.singularize(str, singular) }}
Example
Live Editor
() => tps.utils.singularize("examples")
Result
Loading...
inflect
Usage
{{= tps.utils.inflect(str, count, singular, plural) }}
Example
Live Editor
() => tps.utils.inflect("person", 2))
Result
Loading...
camelize
Usage
{{= tps.utils.camelize(str, low_first_letter) }}
Example
Live Editor
() => tps.utils.camelize("message_properties")
Result
Loading...
underscore
Usage
{{= tps.utils.underscore(str, all_upper_case) }}
Example
Live Editor
() => tps.utils.underscore("MessageProperties")
Result
Loading...
humanize
Usage
{{= tps.utils.humanize(str, low_first_letter) }}
Example
Live Editor
() => tps.utils.humanize("message_properties")
Result
Loading...
capitalize
Usage
{{= tps.utils.capitalize(str) }}
Example
Live Editor
() => tps.utils.capitalize("example text")
Result
Loading...
dasherize
Usage
{{= tps.utils.dasherize(str) }}
Example
Live Editor
() => tps.utils.dasherize("example text")
Result
Loading...
titleize
Usage
{{= tps.utils.titleize(str) }}
Example
Live Editor
() => tps.utils.titleize("example text")
Result
Loading...
demodulize
Usage
{{= tps.utils.demodulize(str) }}
Example
Live Editor
() => tps.utils.demodulize("Message::Bus::Properties")
Result
Loading...
tableize
Usage
{{= tps.utils.tableize(str) }}
Example
Live Editor
() => tps.utils.tableize("MessageBusProperty")
Result
Loading...
classify
Usage
{{= tps.utils.classify(str) }}
Example
Live Editor
() => tps.utils.classify("nav")
Result
Loading...
foreignKey
Usage
{{= tps.utils.foreignKey(str, drop_id_ubar) }}
Example
Live Editor
() => tps.utils.foreignKey("MessageBusProperty")
Result
Loading...
ordinalize
Usage
{{= tps.utils.ordinalize(str) }}
Example
Live Editor
() => tps.utils.ordinalize("1 example")
Result
Loading...
transform
Usage
{{= tps.utils.transform(str, arr) }}
Example
Live Editor
() => tps.utils.transform("example text", [ 'pluralize', 'capitalize', 'dasherize' ])
Result
Loading...