Closed SahilTara closed 5 years ago
what does this mean?
I believe we need to be able to dynamically get the "snake_case", "pascalCase", "kebab-case" and "CamelCase" representations.
Where are they needed and for what reasons?
This is very vague.
As parameters usable within templates during merging.
Okay suppose you are using python and need to change a variable name or something, you would need the snake_case representation. If you are in angular and want to name the folders you should be using the kebab-case representation. Same with the file names of the components.
Even the original unmodified string should be available along with the safe string (symbols and spaces replaced with underscores) for all pages. Currently it only provides the unmodified string so we are forcing it to be safe through converting the page name upfront to be safe. This is ideal for inside the code, but what if I want to use the original name somewhere in the view?
Does this clear things up?
It should always be the original name and I should be able to access the safe name through wts.ItemSafeName, Different casings through wts.ItemKebabCase, .. etc. (names are used for example purposes)
So the consumer would tell Core what naming style to use.
What would this affect? It seems the scope is potentially large. If this impacts item names it will have a knock on effect for all template processing. The impact on WinTS would be huge if it meant changing all existing templates. Need to know everywhere that WebTS needs (potential) changes so that the best/simplest solution can be found for WinTS & WebTS.
This would allow for better naming conventions within our variables and folders. Also possibly better class names. These are the changes required i found through a quick gloss over.
Here All instances of angular grid should be kebab-case for file + foldername. https://github.com/microsoft/WebTemplateStudio/tree/dev/templates/Web/Pages/Angular.Grid/src/app/components/AngularGrid
Similar pattern for the rest of the pages in angular.
Here Param_HomePageName should be guaranteed in a Safe case with underscore. (Similar changes will need to be done in angular+ vue). https://github.com/microsoft/WebTemplateStudio/blob/dev/templates/Web/_composition/ReactJS/Page.React.AddHome/src/App_postaction.jsx
Here wts.ItemName inside the href should be a safe name with underscores, but <a>wts.ItemName</a>
needs to be the exact unchanged item name.
https://github.com/microsoft/WebTemplateStudio/blob/dev/templates/Web/_composition/ReactJS/Page.React.AddNavItem/src/components/NavBar/index_postaction.jsx
My suggestion is we make this feature as backwards compatible with wints as possible. We want to ensure minimal changes in WinTS.
Seems like the only cases completely necessary are:
There might already be sth in dotnet templating that allows to do some of this on the template, we should look at possiblities there first. https://github.com/dotnet/templating/wiki/Runnable-Project-Templates---Value-Forms
Checked in templating engine, they only support lower/upper case for now. Apart from the source name the user specified angular needs kebab case (master-detail) and pascal case (MasterDetail). Plan is to add a wts.tag on the templates to specify which variations of the sourcename should be generated and add them as parameters. To be able to use them for folder renaming we'll also have to add them to the values used to rename folders after generation.
X-Ref Issue for webTS: https://github.com/microsoft/WebTemplateStudio/issues/668
@Tanya0609, apart from kebab case (master-detail) and pascal case (MasterDetail), do we need camelCase too (masterDetail)?
Sample template configuration to use SourceName parameters:
{
...
"tags": {
...
"wts.sourceNameCasing": "kebab|pascal|camel"
},
"symbols": {
...
"wts.sourceName.casing.kebab": {
"type": "parameter",
"replaces": "Param_SourceName_Kebab"
}
}
}
For folder name replacements to work correctly use the following parameter names:
Apart from sourceName casing, WebTS needs casing variations also on some parameters. To allow this, tag will change to wts.casing.[sourceName or parameterName]
Sample template configuration to use SourceName and HomepageName casings:
{
...
"tags": {
...
"wts.casing.sourceName": "kebab|pascal|camel",
"wts.casing.homePageName":"kebab"
},
"symbols": {
...
"wts.sourceName.casing.kebab": {
"type": "parameter",
"replaces": "Param_SourceName_Kebab"
},
"wts.homePageName.casing.kebab": {
"type": "parameter",
"replaces": "Param_HomePageName_Kebab"
}
}
}
Since WebTS is going to be providing support for languages and frameworks, such as python and angular. I believe we need to be able to dynamically get the "snake_case", "pascalCase", "kebab-case" and "CamelCase" representations. This will help in adhering to best patterns and practices (for naming conventions).