3. Keyword Replacement - Replace With Expander

A major strength of CodeStencil is configurable keyword replacement. This means you define keywords ( known as "Expanders") within your Stencil and during code generation,  CodeStencil will replace the Expanders with whatever text you specify.

If you look at the imported Visual Studio generated code, you can see that the name of the project - "WebApplication5" occurs in many places, like in filenames (e.g. WebApplication5.sln", or even as in a folder name. 
We can use the "Replace With Expander" feature to automatically replace these occurences with the Expander.
In this case we are going to replace occurences of  "WebApplication5" with "AspMvcProject".

See Expanders for more documentation.


Step 1: Update the Expander you want to use.

Open an Expander to update the Expansion Label that will be used to replace "WebApplication5". We will be updating the PROJECT_NAME label.


Change the Expansion String :

To: "ProjectMVC" and Save.


Step 2:  Replace with an Expander

This shows some of the strings, folders, filenames, etc. that needs to be replaced with the Expander Label - PROJECT_NAME: 


From the Root node, using the context menu, call the "Replace with Expander" Function.


Select the Expander we need to use - PROJECT_NAME



After the replacement, you can see the changes:


Step 3: Generate the code


Open the generated solution in Visual Studio, you will see the Project name and Solution name is "ProjectMVC":



As you can see, using generated code, we have been able to replicate the Visual Studio ASP.NET MVC template to be used as a stencil within the CodeStencil IDE.

If you want to create another project, all you have to do is to change the Project Name ( In the Expander - See PROJECT_NAME) and generate a new project.



About CodeStencil

CodeStencil is Published and Marketed by Zera Systems Inc.

© 2018-2019 CodeStencil - Zera Systems Inc. All Rights Reserved.

No