-
-
Notifications
You must be signed in to change notification settings - Fork 535
Templates
Rico Suter edited this page Oct 26, 2017
·
37 revisions
Information: To use the new template engine (DotLiquid) you need to enable the setting UseLiquidTemplates. The old T4 templates and the UseLiquidTemplates setting will be removed soon...
Settings (available for all code generators):
- UseLiquidTemplates (default: false, setting will be removed as soon as templates work as expected)
- TemplateDirectory: Location where template overrides are located (you should override only empty/extension templates).
Default Templates:
-
CSharp templates
- Extension templates:
- Class.Annotations
- Class.Constructor
- Class.Property.Annotations
- Extension templates:
-
TypeScript templates
- Extension templates:
- none (please create issue for new extension templates)
- Extension templates:
Template types:
- Extension templates (i.e. empty templates): Can be safely overwritten
- Internal templates (i.e. templates with content): Should be only overwritten for bugfixing (please provide a PR) or when also inserting the original template with
{% template %}
Tags:
-
{% template Foo.Bar %}
: Inserts a template with the same indentation of all lines as the tag -
{% template %}
: Inserts the original template into an overridden template
Filters:
{{ foo | tab: 3 }}
{{ bar | CSharpDocs: 2 }}
Control blocks (if/for/etc.):
- Either use on one line (without -):
foo{% if condition %}bar{% endif %}baz
- ... or on multiple lines (with - at the end):
foo
{% if condition -%}
bar
{% endif -%}
baz
- Use other forms only if really needed (breaks consistency)
DotLiquid templates
TextMate
copy to %USERPROFILE%\.vs\Extensions\
https://github.com/Shopify/liquid-tmbundle
https://github.com/RSuter/NSwag/issues/263
rename to liquid.plist