Skip to the content
Documentation

exp:exptemplateconvert

No ratings yet

Available since Exponential 6.0.15 (in development, not in a release yet).

Summary

Convert the templates of a design from one template engine to another (--from-engine, --to-engine: tpl, stpl, twig); --dry-run, --file, --force, --override-ini, --twig-suffix

Usage

./console exp:exptemplateconvert [options]
php bin/php/exptemplateconvert.php [options]
./console exp:template:convert [options]

Aliases

exp:template:convert

Help

The output of ./console help exp:exptemplateconvert (the script run with --help), without the standard options:

Usage: bin/php/exptemplateconvert.php [OPTION]...
Convert the templates of a design from one template engine to another
Engines: tpl (Exponential templates, .tpl; also exp, exponential), stpl (Smarty templates, .stpl;
also smarty) and twig (Twig templates, .twig and .html.twig). Every template of the --from-engine
below --from becomes the template of the --to-engine at the same place below --to (templates/ and
override/templates/ alike), so that it prints what the source printed. Smarty and Twig convert to
each other through Exponential templates, in memory, in one run. The named commands do the same
with the engines fixed: exp:template:convert:tpl-to-stpl, :stpl-to-tpl, :tpl-to-twig, :twig-to-tpl,
:stpl-to-twig and :twig-to-stpl.

./console exp:template:convert --from-engine=tpl --to-engine=stpl --from=extension/<ext>/design/<design> --to=var/tmp/<design>
./console exp:template:convert --from-engine=stpl --to-engine=tpl --from=var/tmp/<design> --to=var/tmp/<design>-tpl
./console exp:template:convert --from-engine=tpl --to-engine=stpl --from=extension/<ext>/design/<design> --dry-run
./console exp:template:convert --from-engine=tpl --to-engine=stpl --file=design/<design>/templates/<name>.tpl
./console exp:template:convert --from-engine=tpl --to-engine=twig --from=extension/<ext>/design/<design> --to=var/tmp/<design> --twig-suffix=.html.twig

Every written file ends with a marker comment in the target engine's comment syntax
({* exp:template:convert tpl->stpl md5:... from ... *}, {# exp:template:convert tpl->twig ... #});
a target that has no marker, or was changed after it was written, is skipped (SKIP) unless --force
is given. The result is checked before it is written: a .stpl must compile with Smarty 5 and a .twig
with Twig 3 (when installed), a .tpl must parse. Prints WRITE or REPLACE for every file written, NOTE for every
construct that could not be converted exactly, ERROR for a template that could not be converted,
then PASS or FAIL with the counts.
Exit code: 0 PASS; 1 FAIL (a template could not be read, converted, checked or written); 2 wrong
options; 3 the conversion between the two engines is not available.


Options:
  --from-engine=VALUE   the engine of the templates to convert: tpl, stpl or twig
  --to-engine=VALUE     the engine to convert them to: tpl, stpl or twig
  --from=VALUE          design directory with the templates to convert (every template of --from-engine below it)
  --to=VALUE            design directory for the converted templates (default: the --from directory, next to the sources)
  --file=VALUE          convert this one template only (below --from, or a file of its own: then --to is the target file)
  --override-ini=VALUE  override.ini.append.php to write for the --to design (the -s siteaccess's override rules, MatchFile pointing at the converted templates)
  --twig-suffix=VALUE   the ending of written Twig templates: .twig (the default) or .html.twig
  --dry-run             show what would be written; nothing is written
  --force               also replace a target that was changed or written by hand (no marker, or not matching it)

Options

Option Value Description
--from-engine required the engine of the templates to convert: tpl, stpl or twig
--to-engine required the engine to convert them to: tpl, stpl or twig
--from required design directory with the templates to convert (every template of --from-engine below it)
--to required design directory for the converted templates (default: the --from directory, next to the sources)
--file required convert this one template only (below --from, or a file of its own: then --to is the target file)
--override-ini required override.ini.append.php to write for the --to design (the -s siteaccess's override rules, MatchFile pointing at the converted templates)
--twig-suffix required the ending of written Twig templates: .twig (the default) or .html.twig
--dry-run - show what would be written; nothing is written
--force - also replace a target that was changed or written by hand (no marker, or not matching it)

Standard options

Every script also takes the standard options of the script framework: --help, --quiet, --siteaccess, --debug, --colors, --no-colors, --logfiles, --no-logfiles, --verbose and --allow-root-user.

Source

bin/php/exptemplateconvert.php, kernel/private/classes/commands/exptemplateconvert.php

See also

Generated example: exp:exptemplateconvert

Added to the reference for Exponential 6.0.15.

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.