Skip to content

[Bug] Filters - some not working #244

Closed

Description

@ampmonteiro

Version: 2.9.1, 2.5.x
PHP: 7.4.x
OS: Linux

Bug Description

When tried some examples of docs like filters, the output is an error.

Filters that i tried and give me an error: capitalize, webalize and upper.

output error:

<ul>
   <li id="item-1">PHP Fatal error:  Uncaught Error: Call to undefined function Latte\Runtime\mb_convert_case() in latte_project/vendor/latte/latte/src/Latte/Runtime/Filters.php:591
Stack trace:
#0 latte_project/temp/template.latte--eacf53d382.php(21): Latte\Runtime\Filters::capitalize()
#1 latte_project/vendor/latte/latte/src/Latte/Runtime/Template.php(205): Templateeacf53d382->main()
#2 latte_project/vendor/latte/latte/src/Latte/Engine.php(95): Latte\Runtime\Template->render()
#3 latte_project/index.php(8): Latte\Engine->render()
#4 {main}
 thrown in latte_project/vendor/latte/latte/src/Latte/Runtime/Filters.php on line 591

Steps To Reproduce

A stand alone installation without the Nette framework.
The same as the docs, for capitalize filter:

index.php page:

require __DIR__ . '/vendor/autoload.php';

$latte = new Latte\Engine;
$latte->setTempDirectory('temp');
$parameters['items'] = array('one', 'two', 'three');
$latte->render('views/template.latte', $parameters);

views/template.latte:

<ul n:if="$items">
{foreach $items as $item}
   <li id="item-{$iterator->counter}">{$item|capitalize}</li>
{/foreach}
</ul>

Expected Behavior

I expected the code to work, by capitalizing each word

Activity

  1. changed the title [-][Bug] Filters - some are not working[/-] [+][Bug] Filters - some not working[/+] on Nov 28, 2020
  2. milo commented on Nov 28, 2020

    @milo
    Member

    I guess, mbstring extension is missing in your PHP environment. Check out the latte's repo composer.json, the suggest section.

  3. ampmonteiro commented on Nov 28, 2020

    @ampmonteiro
    Author

    I guess, mbstring extension is missing in your PHP environment. Check out the latte's repo composer.json, the suggest section.

    Ok, i installed the mbstring ext and you are right.
    So i suggest, beside the indication stay in composer.json > suggest section, should be added in md file and website docs, filters section.
    And the same for others text in composer.json > suggest section.
    And maybe add to composer.json in require section:

                "require": {
                    "ext-json": "*",
                    "ext-tokenizer": "*",
                    "php": ">=7.1 <8.1"
                },

    By the way, great template engine. :)
    you can close the issue. thanks.

  4. added a commit that references this issue on Nov 30, 2020
    9255b39
  5. added 2 commits that reference this issue on Dec 16, 2020
    8908dc1
    618bf23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions