Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Filters - some not working #244

Closed
ampmonteiro opened this issue Nov 28, 2020 · 2 comments
Closed

[Bug] Filters - some not working #244

ampmonteiro opened this issue Nov 28, 2020 · 2 comments

Comments

@ampmonteiro
Copy link

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

@ampmonteiro ampmonteiro changed the title [Bug] Filters - some are not working [Bug] Filters - some not working Nov 28, 2020
@milo
Copy link
Member

milo commented Nov 28, 2020

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

@ampmonteiro
Copy link
Author

ampmonteiro commented Nov 28, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants