/gmcr

generic simple macro

Primary LanguageLLVMMozilla Public License 2.0MPL-2.0

gmcr

Introduction

GMCR is abbreviation Gonnux's simple MaCRo

It has similar syntax to mustache, yet it is more flexible because you can use lua code inside tags!

You can use GMCR to generate configuration files based on a template

Usage

Installation

git clone --recurse-submodules https://github.com/gonnux/gmcr
cd gmcr
apt install liblua5.3-dev
apt install libboost-dev
apt install libboost-program-options-dev
apt install nlohmann-json-dev
apt install flex
apt install libfl-dev
apt install g++
apt install make
apt install cmake
cd build
cmake ..
make
make install

Syntax

  • a gmcr tag must begin with '#{{' followed by mode modifier string
  • a gmcr tag must end with single white space or newline followed by '}}#'

Tags

Include

#{{i FILEPATH }}#

Code

Your args.json input is saved to the global variable 'args'

#{{c print('any lua5.3 code here') }}#

Example

gmcr -a args.json < template.gmcr > output

args.json example

{"branch": "master"}

template.gmcr example

FROM alpine:latest
#{{c branch = args.branch }}#
RUN apk update && apk add tmux
#{{c if branch == 'dev' then print('apk add git') end }}#
#{{i partial.gmcr }}#

License

Mozilla Public License 2.0