A wrapper for the yaml templating engine gomplate

0.2.1 2025-03-04 14:28 UTC

This package is auto-updated.

Last update: 2025-07-18 21:21:58 UTC


README

Requirements

  • PHP 8.0 or higher
  • Gomplate

Configuration

You can specify the path to the gomplate binary by setting the GOMPLATE_PATH environment variable.

Installation

composer require arcadis-intelligence/gomphplate

Usage

use ArcadisIntelligence\Gomphplate\Gomphplate;

$template = <<<YAML
people:
{{- range .people }}
  - name: {{ .name }}
    age: {{ .age }}
{{- end }}
YAML;

$data = [
    'people' => [
        ['name' => 'Alice', 'age' => 30],
        ['name' => 'Bob', 'age' => 25],
    ],
];

$renderedYaml = Gomphplate::renderYaml($template, $data);

Should produce

people:
  - name: Alice
    age: 30
  - name: Bob
    age: 25