We are excited to unveil the code template editor in GenMyModel.
It’s now possible to create, modify and share Acceleo templates that generate code from your online diagrams. For example, you can design a code template that takes your class diagram and produces your REST API interfaces. Or it could just be your snippet generator. You decide what you generate and everything happens in the browser. The online editor relies on the Acceleo syntax (propulsed by Obeo) and provides live compilation, error checking, syntax coloring, auto-completion, generation preview and run.
How does it work?
In the application, a new panel ‘Generators’ lists the available generators. The template editor opens a new tab next to your diagrams :
The template editor is a Model-to-Text editor. It’s based on Acceleo (an implementation of the Object Management Group MOF Model to Text Language standard) syntax. Basically, a Acceleo template takes a model and writes text in files following its translation rules. The following template takes a UML model as an input and generates one text file per class. It browses the model and fills the generated text files with the class attributes. Here’s the rendering of the template in the editor:
Given the following class diagram:
You can get a preview of the generated code: two files Account.txt and User.txt with the details of their attributes:
You can copy/paste the generated code. The configuration panel also enables you to generate a zip archive or push the generated files to your Git repository:
GenMyModel provides several templates for Java, C#, SQL, C++, PHP, Ruby and Python. You can customize them all. The Pro plan lets you share your template within your organization / team.
You’d like to add a template in our libray to make it available for everyone? Submit it here.
Why generating code online?
You may already have evaluated the time spent coding dumb code. Unit test signatures, configuration files, framework-dependent code, etc: we spend hours every week writing dumb code. We’re all aware of it. The fact is that we usually design our architecture, domain models,etc and the resulting diagrams just remain documentation. The GenMyModel template editor lets you take advantage of the design models you create by producing the tedious parts of your applications. It helps you focus on hard stuff and coding exploits. You don’t let a generator replace your programming style, you design it to generate what you want.
Acceleo uses a template based approach. With this approach, a template is a text containing dedicated part where the text will be computed from elements provided by the inputs models. Those dedicated parts are most of the time expressions specified on the entity of the input models used to select and extract information from those models. For more information, see the Acceleo support page.
We love your feedback. There might be things to improve. Feel free to contact us for any questions or suggestions. Enjoy!