Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ The tool uses [Mustache](https://mustache.github.io/) templating. Please refer t

For each Rive file `{{#riv_files}}`, the following variables are available:

- `{{riv_name}}`: The Rive file name
- `{{riv_pascal_case}}`: The Rive file name in PascalCase
- `{{riv_camel_case}}`: The Rive file name in camelCase
- `{{riv_snake_case}}`: The Rive file name in snake_case
Expand Down Expand Up @@ -173,6 +174,7 @@ For each Rive file `{{#riv_files}}`, the following variables are available:
- `{{property_kebab_case}}`: Name of the property in kebab-case
- `{{property_type}}`: Type information for the property
- For property type `{{#property_type}}`:
- `{{type_name}}`: Name of the type
- `{{is_view_model}}`: Whether the property is a view model
- `{{is_enum}}`: Whether the property is an enum
- `{{is_string}}`: Whether the property is a string
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct ArtboardData

struct RiveFileData
{
std::string rivName;
std::string rivPascalCase;
std::string rivCameCase;
std::string riveSnakeCase;
Expand Down Expand Up @@ -558,6 +559,7 @@ static std::optional<RiveFileData> processRiveFile(const std::string& riveFilePa
std::string fileNameWithoutExtension = path.stem().string();
std::vector<AssetInfo> assets = getAssetsFromFile(riveFile.get());
RiveFileData fileData;
fileData.rivName = fileNameWithoutExtension;
fileData.rivPascalCase = toPascalCase(fileNameWithoutExtension);
fileData.rivCameCase = toCamelCase(fileNameWithoutExtension);
fileData.riveSnakeCase = toSnakeCase(fileNameWithoutExtension);
Expand Down Expand Up @@ -773,6 +775,7 @@ int main(int argc, char* argv[])
{
const auto& fileData = riveFileDataList[fileIndex];
kainjow::mustache::data riveFileData;
riveFileData["riv_name"] = fileData.rivPascalCase;
riveFileData["riv_pascal_case"] = fileData.rivPascalCase;
riveFileData["riv_camel_case"] = fileData.rivCameCase;
riveFileData["riv_snake_case"] = fileData.riveSnakeCase;
Expand Down Expand Up @@ -848,10 +851,10 @@ int main(int argc, char* argv[])
toSnakeCase(property.name);
propertyData["property_kebab_case"] =
toKebabCase(property.name);
propertyData["property_type"] = property.type;

// Add property type information for the viewmodel template
kainjow::mustache::data propertyTypeData;
propertyTypeData.set("type_name", property.type);
propertyTypeData.set("is_view_model",
property.type == "viewModel");
propertyTypeData.set("is_enum", property.type == "enum");
Expand Down
2 changes: 1 addition & 1 deletion templates/json_template.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{#properties}}
"{{property_camel_case}}": {
"name": "{{property_name}}",
"type": "{{property_type}}"
"type": "{{#property_type}}{{type_name}}{{/property_type}}"
}{{^last}},{{/last}}
{{/properties}}
}
Expand Down