Template Library


Model element templates can save you a significant ammount of time and work. Skipper comes with basic predefined templates for example for primary keys, association aliases or entity name. However there is a lot of configurations that can be useful for specific projects. Some of them are available in this article, more can be discussed on our support site.

How to use templates

Templates are used by adding them to the configuration files. You can define templates for all your projects, define them for use in specific ORM or specific single project. This can be specified by storing the template in specific configuration file and by xml definition.

Easiest way how to start with templates is to create new configuration file in directory with your Skipper project file. In example we create file Custom.skipper.cfg.xml. Minimal content of this file can look like this:

<skipper-configuration>
  <global-configuration>
    <element-templates>

      <!-- put your templates here -->
      ...

    </element-templates>
  </global-configuration>
</skipper-configuration>

Warning: In case you override the template that is already defined by configuration file with lower priority, it is necessary to insert the original content to the new template. Templates for same type of element are not merged automatically.

How to extend or create template

You can freely modify, extend or create your own templates. Template XML structure is the same as XML used to store your project files. The simplest way is to create the result entity in Skipper, save your project and copy-paste the model fragment to templates. If you are interested you can check more detailed article about extending templates.

How to extend or create template

You can freely modify, extend or create your own templates. Template XML structure is the same as XML used to store your project files. The simplest way is to create the result entity in Skipper, save your project and copy-paste the model fragment to templates. If you are interested you can check more detailed article about extending templates.

Templates library

Here you will find list of templates you can use for your project. It is a compilation of both templates we are using for our internal project, and templates from our other users. If you want to share your own templates, or you have an idea about new templates, let us know on our support site.

1. Automatically create fields for new entity

You can add recurring fields to all your entities automatically. The common usage is for example primary key, created_at and updated_at fields.


<template element='entity' use-case='create'>
  <entity>
    <field name="id" type="integer" required="true" unique="true" primary="true"
           auto-increment="true"/>
    <field name="created_at" type="datetime" required="true"/>
    <field name="updated_at" type="datetime" required="true"/>
  </entity>
</template>

2. Customize automatic naming convention

You can have prefixes added to your entity names automatically.


<template element='entity' use-case='create'>
  <entity name="entityXX"/>
</template>

3. Update ORM attributes based on entity name

You can have the ORM attributes based on entity name and update them automatically. In our example the table_name and value is updated with every change of the entity.


<template element='entity' use-case='update'>
  <entity>
    <orm-attributes>
      <attribute name="db_table">db_{entity#UL}</attribute>
    </orm-attributes>
  </entity>
</template>

4. Define entity namespace by project and module

You can automatically set namespace for each new entity based on you project and module name.


<template element='entity' use-case='create'>
  <entity>
    <orm-attributes>
      <attribute name="namespace">{project#CFU}\{module#CFU}</attribute>
    </orm-attributes>
  </entity>
</template>

5. Automatically add behaviors to each new entity

When you are using common behaviors on most of your entities (for example SoftDelete and Timestampable) you can have them preset by templates.


<template element='entity' use-case='create'>
  <entity>
     <orm-attributes>
        <attribute name="actAs">
          <attribute name="SoftDelete"/>
          <attribute name="Timestampable"/>
        </attribute>
      </orm-attributes>
  </entity>
</template>

6. Customize association aliases

You can set up naming convention for associations and naming rules for the aliases.


<template element='association' use-case='create'>
	<association caption="{entity-inverse} to {entity-owner}"
				 owner-alias="{entity-owner#UL}"
				 inverse-alias="{entity-inverse#UL}"/>
</template>

7. Customize manyToMany entity

You can set up unified naming convention for many-to-many entities.


<template element='many-to-many' use-case='create'>
  <many-to-many mn-entity="{entity-inverse}2{entity-owner}"/>
</template>

8. Predefined module options

You can avoid necessity to enter recurring module options to new created module.


<template element='module' use-case='create'>
  <module>
    <orm-attributes>
      <attribute name="options">
        <attribute name="charset">utf8</attribute>
        <attribute name="collate">utf8_czech_ci</attribute>
        <attribute name="type">INNODB</attribute>
      </attribute>
    </orm-attributes>
  </module>
</template>

9. Automatic column name

Generates column name from the name of the field. Uses the substitution mark combined with naming style.


<template element="field" use-case="update">
	<field>
		<orm-attributes><attribute name="column">{field#CFU}</attribute></orm-attributes>
	</field>
</template>

10. Set up default color scheme for new object

You can set up your own color scheme for all objects.


<template element='entity' use-case='create'>
  <entity bk-color="4278255360" hdr-color="4278190335">
  </entity>
</template>

<template element='association' use-case='create'>
  <association color="4294901760">
  </association>
</template>