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

Smarty 5: registerPlugin() no longer working with names containing non-lowercase characters #907

Closed
m-ober opened this issue Sep 15, 2023 · 3 comments · Fixed by #910
Closed

Comments

@m-ober
Copy link

m-ober commented Sep 15, 2023

This should output "Test" but gives the following error in Smarty 5 / dev-master. Working with latest 4.x version.

Smarty\CompilerException: Syntax error in template "string:{customTag}" on line 1 "{customTag}" unknown tag 'customtag' in string:{customTag} on line 1

<?php

require 'vendor/autoload.php';

use Smarty\Smarty;
//use \Smarty;

class Functions
{
    public static function customTag()
    {
        return 'Test';
    }
}

$smarty = new Smarty();
$smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'customTag', [Functions::class, 'customTag']);
$smarty->display('string:{customTag}');
@wisskid
Copy link
Contributor

wisskid commented Sep 17, 2023

Might be problem with case sensitivity. Does it work when you change the registerPlugin line as follows?
$smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'customtag', [Functions::class, 'customTag']);

@m-ober
Copy link
Author

m-ober commented Sep 17, 2023

Yes, with this change it's working again. But that would require a lot of refactoring in all templates...

@m-ober m-ober changed the title Smarty 5: registerPlugin() no longer working Smarty 5: registerPlugin() no longer working with names containing non-lowercase characters Sep 17, 2023
@wisskid
Copy link
Contributor

wisskid commented Sep 17, 2023

No worries, we'll fix this. Should be easy! Thank you for your bug report.

Jack-Dane added a commit to Jack-Dane/smarty-fix-case-sensitive-tag that referenced this issue Oct 1, 2023
* Don't lower tags until they are used for extensions so custom tags can be case-sensitive.
Jack-Dane added a commit to Jack-Dane/smarty-fix-case-sensitive-tag that referenced this issue Oct 1, 2023
* Don't lower tags until they are used for extensions so custom tags can be case-sensitive.
wisskid pushed a commit that referenced this issue Oct 22, 2023
* Don't lower tags until they are used for extensions so custom tags can be case-sensitive.
wisskid pushed a commit that referenced this issue Nov 6, 2023
* Don't lower tags until they are used for extensions so custom tags can be case-sensitive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants