Assets 20

This is a huge release because uh... I haven't done a release in a year. Oops.

But this one is important, it adds support for template engines, which means you can use any template system you want - jinja, amber, ace, whatever. As long as you can render templates via a command line tool, you can use that templating system.


f9a0cde fix magefile
f8bfaf8 start using goreleaser (#110)
23a95a3 add support for template engines (#109)
5cec2b8 fix a bunch of highlighting stuff on the website (#108)
b89c261 rename index function so it doesn't overlap with built-in (#106)
5508f6a Add test for Sorted
d59abbf fix magefile
8c14df8 fix sorted method on Strings
3c40e89 fix list in docs
2d7cbaf Sort and docs (#105)
6d61ec9 fix: passing the table DB name to the enum-generation steps (#99)
d696814 Abort generation if file exists and matches glob (#91)
25eb64a surface index uniqueness (#88)
ca6baf0 expose column comments (#85)
61fec0c ensure consistent index ordering (#83)
5c998ea introduce new funcs to ForeignKeyColumns (#81)
f271111 use queryForeignKeys in parse.go (#80)
bb0f0f1 check for public schema before trimming table name (#76)
ae5317d add support for indexes (#70)
8d67147 Convert []interface{} to []string from plugins (#66)
a894efd Added Bi-Directional Foreign Keys (#63)
80d3e58 fix the mysql template (#69)
a634174 fix postgres enums (#68)
4b0d4dc Add missing config items to configdata (#67)
5b20ff0 add except method (#65)
973f5d9 add numbers function (#59)
0ba6eb2 make static dir with init (#58)
06cb323 fix-vendor (#55)
127ccf7 fix init and add test for it (and update deps) (#54)
d8cc902 prepend outputdir on generated files & cleanup (#49)
1e353a6 Adds Primary Key Information To Tables and Columns (#50)
a5c1d6c Support static files (#45)
468b75c Updates documentation to reference mage build instead of go run make.go (#48)
7675fdc Add support for template plugin (#35)
38c7bb1 ignore site and vendor dirs for github stats (#44)
b4bdadf Use ioutil.WriteFile instead of atomic.WriteFile (#42)
9354db9 use mage deps and cleanup (#40)
0fd0729 Add link to (#38)
bc1de9a start using a magefile (#37)
2f19124 preview updates (#36)
a973ffc Gnorm docs (#34)
f420e3f readme cleanup
67f6bd3 add build badge to readme (#30)
b012c9d update travis config (#29)
3ee7171 Run dep ensure to add package (#26)

@natefinch natefinch released this Sep 18, 2017 · 47 commits to master since this release

Assets 8

A lot of rework has been done under the covers, with a few new features and new data layout.

Command Changes

New: gnorm init

gnorm init produces a default gnorm.toml file and template files to help you get started with gnorm.

Configuration Changes

Removed: TemplateDir

Because of the change to support multiple output file/content template pairs, a dedicated value of where templates live isn't necessary, you can specify the relative path for each content template directly.

Changed: SchemaPath, TablePath, EnumPath -> SchemaPaths, TablePaths, EnumPaths

You may now specify any number of output targets for each content template type. TablePath, EnumPath, and SchemaPath are now toml tables called SchemaPaths, TablePaths, EnumPaths, allowing you to specify multiple output target / content template pairs for each.

For example (note the s on the end of the name in brackets):

"{{.Schema}}/tables/{{.Table}}/{{.Table}}.go" = "tableORM.tmpl"
"public/{{.Schema}}/tables/{{.Table}}.html" = "tableHTML.tmpl"


To translate an old style single value `TablePath = "some/filepath/template", use the template string on the left, as above, and "table.gotmpl" as the template name on the right. (enums expect "enum.gotmpl" and schemas "schema.gotmpl"). And don't forget to include the TemplateDir if you used one before.


Because these are toml tables, they need to be at the end of the configuration with the rest of the tables. There can't be any standalone values after them.

Gnorm doesn't care what the extension of the file is for the template, so use whatever you like.

New: Params

There is now a [Params] table in the config which can hold whatever data you want. This data will be accessible to templates via the .Params data value for every content type.

For example:

showHidden = true
myName = "Bob"

Data Changes

New artisanal, hand written docs about data!

Data has changed a lot... but with minimum impact on existing templates. The data layout for Tables, Schema, and Enums has had a bunch of things added at the top level. Every template now receives all the data about the DB in a .DB value. It also receives much of the data from the config file in a .Config value. Finally, the Params from the config file are available in .Params. The previous top-level data for Tables, Schema, and Enums are now available in .Table, .Schema, and .Enum respectively.

See for more information


To use your existing template, it's just a matter of putting {{with .Table}} (or .Enum or .Schema as appropriate) at the top of your content template and {{end}} at the end of the template, and then the values will be the same as before, with two exceptions: in tables and enums, the .Schema value is now a reference to the actual schema object. to get its name or DBname, substitute .Schema.Name for the old template's .Schema, and .Schema.DBName for the old template's .DBSchema.


@natefinch natefinch released this Sep 7, 2017 · 62 commits to master since this release

Assets 8

This is an initial release. Gnorm works but needs a lot more tests to ensure production quality. See for details.