Partials
You can split up big template files into multiple smaller files, by creating .partial.mustache
files. The filename of this file without the .partial.mustache
extension will be used as the id of the partial.
For example, you can create the csharp-entity-class.partial.mustache
file:
/** {{{entity.description}}} */
class {{pascalCase entity.name}}
{
{{#each entity.fields}}
/** {{{description}}} */
{{type.cs}} {{pascalCase name}} { get; set; }
{{/each}}
}
NOTE
We are using {{entity.name}}
and {{entity.fields}}
. This is because the whole entity will be passed as an argument to this partial, with the entity
name.
We can use this in a .ptemplate.mustache
file like this:
{
"forEach": "entities",
"filename": "Entities/{{pascalCase name}}.cs"
}
---
using System;
namespace Entities
{
{{> csharp-entity-class entity=this }}
}
All partials will always be loaded by ProJor from the .projor
directory before starting code generation, and will be available in all templates.