Manaita

Simple Markdown-Driven Code Generator written by Go

Write your scaffolding code on CODEGEN.md and generate files using the scaffold.

Template file is Markdown format. so you can see it on Github and easily understand what will be generated.

manaita

Installation

Brew

brew install igtm/tap/manaita

Go Install

go install github.com/igtm/[email protected]

Getting Started

  1. put CODEGEN.md on your directory

---
Params:
- name
---

# foo.go

```golang
package foo

var foo = "foo"
```


# {{.Params.name}}/bar.py

```python
print("bar.py")
```
  1. Run manaita -p name=dog
  2. foo.go and dog/bar.py files are generated

Usage

manaita -c ./path/to/CODEGEN.md -p key=value

Available options:

  -c                  specify markdown template file path. default name is 'CODEGEN.md'
  -p                  specify parameters for code gen. these must be defined on markdown  e.g. '-p foo=bar,fizz=buzz'

Available template params:

  {{.Env}}            can access environment variables
  {{.Params}}         can access given parameters by '-p' option, which must be defined on 'Params' field of markdown header.

Available template functions:

AnyKind of_string

Function Result
ToUpper ANY KIND OF_STRING
ToLower anykind of_string
ToSnake any_kind_of_string
ToScreamingSnake ANY_KIND_OF_STRING
ToKebab any-kind-of-string
ToScreamingKebab ANY-KIND-OF-STRING
ToCamel AnyKindOfString
ToLowerCamel anyKindOfString

This library uses Go Template.

so you can use any Go Template syntax like ‘{{if foo}} .. {{end}}’ and like that.

references

GitHub

View Github