You are here

function twig_first in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Extension/Core.php \twig_first()

Returns the first element of the item.

Parameters

Twig_Environment $env A Twig_Environment instance:

mixed $item A variable:

Return value

mixed The first element of the item

1 call to twig_first()
Twig_Tests_Extension_CoreTest::testTwigFirst in vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php
1 string reference to 'twig_first'
Twig_Extension_Core::getFilters in vendor/twig/twig/lib/Twig/Extension/Core.php

File

vendor/twig/twig/lib/Twig/Extension/Core.php, line 754

Code

function twig_first(Twig_Environment $env, $item) {
  $elements = twig_slice($env, $item, 0, 1, false);
  return is_string($elements) ? $elements : current($elements);
}