Download the PHP package stann/google-docs-handlebars without Composer

On this page you can find all versions of the php package stann/google-docs-handlebars. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package google-docs-handlebars

Google Docs Handlebars

Renders a Handlebars-subset template inside a Google Doc, in place, through the Google Docs API.

Text template engines produce a string. This one produces a plan of documents.batchUpdate operations: table rows are duplicated for loops, discarded blocks are deleted, and every {{tag}} is replaced — while the document keeps its layout, styles, headers and footers. The document itself (usually a fresh copy of a template document) is the rendering target.

The package has no dependency — not even on an HTTP client: you hand it a tiny DocumentClient adapter and it never talks to the network itself.

Installation

Quick start

Values must be display-ready strings: the engine never formats numbers, dates or currencies — that is the integrator's concern.

Template syntax

The grammar is a strict subset of Handlebars. Templates stay portable: what renders here renders identically under handlebars.js.

Construct Example Notes
Variable {{customer.name}} Dotted paths into the context.
Comment {{!-- draft note --}} / {{! note }} Removed from the output.
Condition {{#if quotation.reference}} ... {{/if}} Keeps or deletes the block.
Negated condition {{#unless customer.address}} ... {{/unless}} Inverse of #if.
Loop {{#each items}} ... {{/each}} On a table row — see below.
Loop item {{item.name}}, {{item.totalAmount}} Current row of the loop.
Loop index {{@index}} Zero-based position.
Helper {{date "DD/MM/YYYY" quotation.dueAt}} Registered at construction — see below.

Truthiness follows Handlebars: absent, null, false, '', 0 and empty lists are falsy.

A variable whose path does not exist in the context is left as-is in the document, so template mistakes stay visible instead of silently disappearing.

Helpers

The engine ships no helper: formatting is the integrator's concern. Register them at construction; arguments reach the callable in template order, string literals as written and paths resolved through the context ('' when absent):

An unregistered helper raises UnsupportedFeatureError; helpers cannot be applied to loop variables (item.*, @index) yet.

Everything else is rejected on purpose

{{else}}, partials ({{> x}}), subexpressions, {{#with}}, block parameters (as |x|), nested blocks, parent references (../), @first / @last, and triple-stache ({{{x}}}) raise an UnsupportedFeatureError with a message suitable for template authors. Malformed constructs (unclosed block, mismatched closer, invalid path) raise a TemplateSyntaxError.

Placement rules (document structure)

Because rendering mutates a real document, blocks must map onto units the Docs API can manipulate:

Violations raise a TemplateStructureError explaining what to move.

Headers, footers and footnotes are replace-only surfaces: they are parsed like the body, so {{variables}} (whatever their spacing) and comments work there, but blocks and loop variables are rejected — the Docs API cannot structurally edit those segments.

How it renders

TemplateEngine::render() issues at most three batchUpdate calls:

  1. Structure — delete discarded condition blocks, insert the empty loop rows (bottom-up, so indexes stay valid).
  2. Loop fill — after re-reading the document (insertions shifted every index), write each copy's cell texts, pre-rendered per item, preserving the prototype row's text style and alignment.
  3. Replacements — global replaceAllText for variables, comments and loop markers; the prototype row becomes item #0.

Nothing is sent when a step has no work to do.

Errors

Every failure extends Stann\GoogleDocsTemplate\Exception\TemplateError:

Error Meaning
TemplateSyntaxError Malformed construct (unclosed block, invalid path...). Carries the offending ->tag.
UnsupportedFeatureError Valid Handlebars, outside the supported subset. Carries ->tag.
TemplateStructureError Tags valid but placed incompatibly with the document structure. Carries ->tag when identifiable.
InvalidDocumentError The fetched document resource itself is unusable (no body...).

All messages are written for the person editing the template.

The public API is TemplateEngine, the DocumentClient interface, the exceptions and the Testing\ namespace — everything else is @internal.

Testing

The Stann\GoogleDocsTemplate\Testing namespace ships test doubles so integrators can test without any Google access:

The suite itself runs offline:

Requirements

PHP ≥ 8.2 with ext-mbstring. No other dependency.


All versions of google-docs-handlebars with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stann/google-docs-handlebars contains the following files

Loading the files please wait ...