Download the PHP package creative-sizzle/wn-twigextensions-plugin without Composer

On this page you can find all versions of the php package creative-sizzle/wn-twigextensions-plugin. 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 wn-twigextensions-plugin

Twig extensions

Build Status Codacy Scrutinizer Coverage License

Twig extensions plugin for OctoberCMS adds new filter and functions to your templates. No other plugin dependencies.

Tested with the latest stable OctoberCMS build 420 (with Laravel 5.5). For Laravel 5.4 use special branch laravel54.

Installation

Install plugin from CMS backend or by Composer:

Than you can use newly added filters/functions at your templates:

Available functions

config, env, session, trans, var_dump, template_from_string

config

Function move the functionality of the Laravel config() helper function to Twig.

The example would output the value currently stored in app.locale. See more about the Laravel config helper function here.

env

Function move the functionality of the Laravel env() helper function to Twig.

The example would output the value currently stored in APP_ENV environment variable. Second parameter is default value, when ENV key does not exists.

session

Function move the functionality of the Laravel session() helper function to Twig.

The example would output the value currently stored in my.session.key. See more about the Laravel session helper function here.

trans

Function move the functionality of the Laravel trans() helper function to Twig.

The example would output a value stored in a localization file of an imaginary blog plugin. See more about localization in October CMS here.

var_dump

Dumps information about a variable. Can be also used as filter.

template_from_string

Function loads a template from a string.

Available filters

strftime, uppercase, lowercase, ucfirst, lcfirst, ltrim, rtrim, str_repeat, plural, truncate, wordwrap, strpad, str_replace, strip_tags, leftpad, rightpad, rtl, shuffle, time_diff, localizeddate, localizednumber, localizedcurrency, mailto, var_dump, revision, sortbyfield

strftime

Format a local time/date according to locale settings.

The example would output Posted at 04.01.2016 22:57:42. See more format parameters.

uppercase

Make a string uppercase.

The example would output Hello I'm JACK.

lowercase

Make a string lowercase.

The example would output Hello I'm jack.

ucfirst

Make a string's first character uppercase.

The example would output Hello I'm Jack.

lcfirst

Make a string's first character lowercase.

The example would output Hello I'm jack.

ltrim

Strip whitespace (or other characters) from the beginning of a string.

The example would output Hello I'm jack without whitespaces from the start.

rtrim

Strip whitespace (or other characters) from the end of a string.

The example would output Hello I'm jack without whitespaces from the end.

str_repeat

Repeat a string.

The example would output I'm the best best best!

plural

Get the plural form of an English word.

The example would output You have 1 new mail or You have 3 new mails - depending on mails count.

truncate

Use the truncate filter to cut off a string after limit is reached.

The example would output Hello..., as ... is the default separator.

You can also tell truncate to preserve whole words by setting the second parameter to true. If the last Word is on the the separator, truncate will print out the whole Word.

Here Hello World! would be printed.

If you want to change the separator, just set the third parameter to your desired separator.

This example would print Hello W??.

wordwrap

Use the wordwrap filter to split your text in lines with equal length.

This example would print:

The default separator is "\n", but you can easily change that by providing one:

This would result in:

strpad

Pad a string to a certain length with another string from both sides.

This would print:

str_replace

Replace all occurrences of the search string with the replacement string.

This would return:

strip_tags

Strip HTML and PHP tags from a string. In first parameter you can specify allowable tags.

This would return:

leftpad

Pad a string to a certain length with another string from left side.

This would print:

rightpad

Pad a string to a certain length with another string from right side.

This would print:

rtl

Reverse a string.

This would print:

shuffle

Shuffle an array.

or in foreach:

time_diff

Use the time_diff filter to render the difference between a date and now.

The example above will output a string like 4 seconds ago or in 1 month, depending on the filtered date.

Output is translatable. All translations are stored at /lang folder in this plugin. If you want more locales, just copy them from this repository, replace %count% with :count and send it as pull reqest to this repository.

Arguments

Translation

To get a translatable output, give a Symfony\Component\Translation\TranslatorInterface as constructor argument. The returned string is formatted as diff.ago.XXX or diff.in.XXX where XXX can be any valid unit: second, minute, hour, day, month, year.

localizeddate

Use the localizeddate filter to format dates into a localized string representating the date. Note that php5-intl extension/php7-intl extension has to be installed!

The localizeddate filter accepts strings (it must be in a format supported by the strtotime function), DateTime instances, or Unix timestamps.

Arguments

localizednumber

Use the localizednumber filter to format numbers into a localized string representating the number. Note that php5-intl extension has to be installed!

Internally, Twig uses the PHP NumberFormatter::create() function for the number.

Arguments

localizedcurrency

Use the localizedcurrency filter to format a currency value into a localized string. Note that php5-intl extension has to be installed!

Arguments

mailto

Filter for rendering email as normal mailto link, but with encryption against bots!

returns

which will be rendered to page as normal

PHP encrypts your email address and generates the JavaScript that decrypts it. Most bots can't execute JavaScript and that is what makes this work. A visitors of your web page will not notice that you used this script as long as they has JavaScript enabled. The visitors will see "[javascript protected email address]" instead of the email address if they has JavaScript disabled.

Filter parameters

var_dump

Dumps information about a variable.

revision

Force the browser to reload cached modified/updated asset files. You can provide a format parameter so that the prepended timestamp get converted accordingly to the PHP date() function.

usage

Will return something like

See: https://github.com/vojtasvoboda/oc-twigextensions-plugin/issues/25

https://stackoverflow.com/questions/32414/how-can-i-force-clients-to-refresh-javascript-files

http://php.net/manual/en/function.date.php

sortbyfield

Sort array/collection by given field (key).

Output will be: John David

Contributing

Feel free to send pullrequest! Please, send Pull Request to master branch.

License

Twig extensions plugin is open-sourced software licensed under the MIT license same as OctoberCMS platform.


All versions of wn-twigextensions-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
twig/extensions Version ~1.5.1
symfony/translation Version ~3.3.9
composer/installers Version ~1.4
snilius/twig-sort-by-field Version dev-master
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 creative-sizzle/wn-twigextensions-plugin contains the following files

Loading the files please wait ....