Download the PHP package vojtasvoboda/oc-twigextensions-plugin without Composer

On this page you can find all versions of the php package vojtasvoboda/oc-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 oc-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 3.1.18 on PHP 8.0.

Versions

There are two versions of this plugin - 1.x and 2.x. For older October 1.0.x, 1.1.x or 2.x.x use special branch 1.x. For October 3.1+ use master branch. For old Laravel 5.4 October's versions use special branch laravel54.

For migrating between plugin's version 1 and version 2 you can use special UPGRADE.md guide.

Installation

Install plugin from CMS backend or by Composer:

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

Available functions

session, trans, var_dump, template_from_string, country_timezones

session

Function moves 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.

You can also use OctoberCMS function: {{ this.session.get('my.session.key') }}, but it's little bit longer :-)

trans

Function moves 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.

You can also use trans filter: {{ 'acme.blog::lang.app.name'|trans }}.

var_dump

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

You can also use {{ dump(users) }} function to dump information about a variable. Properties are "clickable" to expand.

template_from_string

Function loads a template from a string.

country_timezones

The country_timezones function returns the names of the timezones associated with a given country code:

Available filters

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.

You can also use {{ carbon(article.date).formatLocalized('%d.%m.%Y %H:%M:%S') }}.

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.

You can also use {{ ' I like Twig. '|trim(side='left') }} native Twig filter.

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.

You can also use {{ ' I like Twig. '|trim(side='right') }} native Twig filter.

var_dump

Dumps information about a variable.

You can also use <pre>{{ var_dump(users) }}</pre> or {{ dump(users) }} functions.

wordwrap

Use the wordwrap filter to split your text into 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:

revision

Force the browser to reload cached modified/updated asset files. You can provide a format parameter so that the prepended timestamp gets 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

country_name

The country_name filter returns the country name given its ISO-3166 two-letter code:

By default, the filter uses the current locale. You can pass it explicitly:

currency_name

The currency_name filter returns the currency name given its three-letter code:

By default, the filter uses the current locale. You can pass it explicitly:

currency_symbol

The currency_symbol filter returns the currency symbol given its three-letter code:

By default, the filter uses the current locale. You can pass it explicitly:

language_name

The language_name filter returns the language name given its two-letter code:

By default, the filter uses the current locale. You can pass it explicitly:

locale_name

The locale_name filter returns the locale name given its two-letter code:

By default, the filter uses the current locale. You can pass it explicitly:

timezone_name

The timezone_name filter returns the timezone name given a timezone identifier:

By default, the filter uses the current locale. You can pass it explicitly:

format_currency

The format_currency filter formats a number as a currency:

You can pass attributes to tweak the output:

The list of supported options:

By default, the filter uses the current locale. You can pass it explicitly:

formatnumber and format*_number

The format_number filter formats a number:

You can pass attributes to tweak the output:

The list of supported options:

Besides plain numbers, the filter can also format numbers in various styles:

The list of supported styles:

As a shortcut, you can use the format__number filters by replacing `` with a style:

You can pass attributes to tweak the output:

By default, the filter uses the current locale. You can pass it explicitly:

format_datetime

The format_datetime filter formats a date time:

Format

You can tweak the output for the date part and the time part:

Supported values are: none, short, medium, long, and full.

For greater flexibility, you can even define your own pattern (see the ICU user guide for supported patterns).

Locale

By default, the filter uses the current locale. You can pass it explicitly:

Timezone

By default, the date is displayed by applying the default timezone (the one specified in php.ini or declared in Twig -- see below), but you can override it by explicitly specifying a timezone:

If the date is already a DateTime object, and if you want to keep its current timezone, pass false as the timezone value:

The default timezone can also be set globally by calling setTimezone():

format_date

The format_date filter formats a date. It behaves in the exact same way as the format_datetime filter, but without the time.

format_time

The format_time filter formats a time. It behaves in the exact same way as the format_datetime filter, but without the date.

Removed functions

Functions used in plugin's version 1.x for October 1.0.x, 1.1.x, 2.0.x and removed from this version:

Removed filters

Filters used in plugin's version 1.x for October 1.0.x, 1.1.x, 2.0.x and removed from this version:

For more info see UPGRADE.md guide.

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 oc-twigextensions-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.2
october/rain Version ^3.0
composer/installers Version ~1.0
twig/intl-extra Version ^3.4
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 vojtasvoboda/oc-twigextensions-plugin contains the following files

Loading the files please wait ....