gnormal / gnorm

A database-first code generator for any language
https://gnorm.org
Other
484 stars 39 forks source link

add support for template engines #109

Closed natefinch closed 6 years ago

natefinch commented 6 years ago

This adds a TemplateEngine section to the config, which lets you use an external (CLI) template engine and render whatever kind of templates you like.

# TemplateEngine, if specified, describes a command line tool to run to
# render your templates, allowing you to use your preferred templating
# engine.  If not specified, go's text/template will be used to render.
[TemplateEngine]
    # CommandLine is the command to run to render the template.  You may
    # pass the following variables to the command line - 
    # {{.Data}} the name of a .json file containing the gnorm data serialized into json
    # {{.Template}} - the name of the template file being rendered
    # {{.Output}} the target file where output should be written 
    CommandLine = ["yasha", "-v", "{{.Data}}", "{{.Template}}", "-o", "{{.Output}}"]

    # If true, the json data will be sent via stdin to the rendering tool.
    UseStdin = false

    # If true, the standard output of the tool will be written to the target file.
    UseStdout = false
natefinch commented 6 years ago

This needs tests and then will be ready to land.