tyz910/docx-templates

There is no license information available for the latest version (0.9.1) of this package.

Simple template engine for .docx

0.9.1 2015-03-19 07:30 UTC

This package is not auto-updated.

Last update: 2024-11-18 14:13:16 UTC


README

Latest Stable Version Build Status Coverage Status Scrutinizer Quality Score

You can create a .docx template file with included search-patterns that can be replaced by any value you wish:

<?php
use DocxTemplate\TemplateFactory;

$template = TemplateFactory::load('template1.docx');
$template->assign([
    'name'    => 'Jon',
    'surname' => 'Snow',
    'house'   => 'Stark'
]);
$template->save('jon.docx');

Search-pattern spelling

Default search-pattern spelling is: {{mark_name}}
Mark name should be lowercase, with words separated by underscores.

My name is {{name}}.

Also you can use any search-pattern spelling you wish:

<?php
use DocxTemplate\TemplateFactory;

TemplateFactory::useMarkSyntax('${', '}'); // prefix and suffix
$template = TemplateFactory::load('template.docx');

Installation using Composer

Add to your composer.json:

{
    "require" :  {
        "tyz910/docx-templates": "*"
    }
}