Download the PHP package nedryse/latte-template-macroset without Composer

On this page you can find all versions of the php package nedryse/latte-template-macroset. 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 latte-template-macroset

nedryse/latte-template-macroset (cc)

Pavel Železný (2bfree), 2014 (pavelzelezny.cz)

Requirements

Nette Framework 2.2.0 or higher

Documentation

Placeholder replacement Latte macro provides simple way to put the content of variables into the right places.

Macroset provides {template ...} macro and overwrites {_ ...} macro with same mechanism. First argument of these macros can contain any number of {:placeholders} in the string that will be replaced by the same named variables.

Replacement variables are taken from the template like $template->placeholder, are overwritten by local variable like {var $placeholder} and are overwritten by arguments of macros like {template ..., 'placeholder' => 'replacement', ...} or {template ..., array('placeholder' => 'replacement', ...)}. Replacement variables can contain {:nested_placeholders}, that will be replaced also.

The functionality of {_ ...} macro is maintained. All arguments of the macro are sended to the translator unchanged. Result of the translator will be used as template that can contain {:placeholders}. With this functionality you can change the possition of given arguments to provide propper number of translator plurals as the first argument of the macro.

Instalation

Prefered way to intall is by Composer

composer require nedryse/latte-template-macroset:~1.0.0

Or by manualy adding into the composer.json

{
    "require":{
        "nedryse/latte-template-macroset": "~1.0.0"
    }
}

Setup

Add following code into the config.neon

common:
    extensions:
        latteTemplateMacroSet: Nedryse\Latte\Macros\TemplateMacroSetExtension

Usage

The simpliest usage is like the following code:

{template '<strong>{:userName}</strong>', 'userName' => $user->getIdentity()->getId()}

Replacement variables can be given by the array also like in the following code:

{var $replacements = array('userName' => $user->getIdentity()->getId())}
{template '<strong>{:userName}</strong>', $replacements}

Replacement variables can be given from {var ...} or from $template like in the following code:

{var $userName => $user->getIdentity()->getId()}
{template '<strong>{:userName}</strong>'}

Replacements can be overwritten in the order $template, {var ...}, {template ..., replacements} like in the following code:

{var $userName => $user->getIdentity()->getId()}
{template '<strong>{:userName}</strong>', 'userName' => 'test'}

Both macros also support filters like in the following code:

{template '<strong>{:userName}</strong>', 'userName' => 'test'|upper}

Replacements can contain {:nested_placeholders} to be used as customizable template mechanism like in the following code:

{var $idTpl = '<strong>{:userId}</strong>'}
{var $nameTpl = '{:userName}'}
{var $pairTpl = '<li>{:idTpl} - {:nameTpl}</li>'}
{var $usersTpl = '<ul>{:usersListTpl}</ul>'}
{capture $usersListTpl}
    {foreach $users as $userId => $userName}
        {template $pairTpl}
    {/foreach}
{/capture}

{_'User (%s): {:usersTpl}', count($users)}

All versions of latte-template-macroset with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.1
latte/latte Version ~2.2
nette/di Version ~2.2
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 nedryse/latte-template-macroset contains the following files

Loading the files please wait ....