diff --git a/README.md b/README.md index dcdae6f..79feaa3 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 80d3a75..2c15312 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -110,6 +110,7 @@ struct ArtboardData struct RiveFileData { + std::string rivName; std::string rivPascalCase; std::string rivCameCase; std::string riveSnakeCase; @@ -558,6 +559,7 @@ static std::optional processRiveFile(const std::string& riveFilePa std::string fileNameWithoutExtension = path.stem().string(); std::vector assets = getAssetsFromFile(riveFile.get()); RiveFileData fileData; + fileData.rivName = fileNameWithoutExtension; fileData.rivPascalCase = toPascalCase(fileNameWithoutExtension); fileData.rivCameCase = toCamelCase(fileNameWithoutExtension); fileData.riveSnakeCase = toSnakeCase(fileNameWithoutExtension); @@ -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; @@ -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"); diff --git a/templates/json_template.mustache b/templates/json_template.mustache index 1aaf020..f0e4897 100644 --- a/templates/json_template.mustache +++ b/templates/json_template.mustache @@ -33,7 +33,7 @@ {{#properties}} "{{property_camel_case}}": { "name": "{{property_name}}", - "type": "{{property_type}}" + "type": "{{#property_type}}{{type_name}}{{/property_type}}" }{{^last}},{{/last}} {{/properties}} }