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

Custom macro which starts with underscore #226

Closed
awps opened this issue Jun 4, 2020 · 2 comments
Closed

Custom macro which starts with underscore #226

awps opened this issue Jun 4, 2020 · 2 comments
Milestone

Comments

@awps
Copy link

awps commented Jun 4, 2020

Version: 2.8.1

Bug Description

I'm trying to create a macro which is starting with an underscore and it fails on thinking that it's a translation.

Also using a php function that starts with underscore fails as well.

In my case I'm trying to use this function __(): https://developer.wordpress.org/reference/functions/__/

Using the function directly or creating a macro, the problem still persists.

Steps To Reproduce

<a href="#" class="button">{__('Get an estimation', 'domain')}</a>
$this->latte->addFunction('__', [$this, '__']);
//...
public function __($text, $domain = 'default')
{
   return __($text, $domain);
}

Expected Behavior

Should execute the actual function __(), not trying to use the translation filter.

I'm using only the Latte engine and Tracy, without Nette framework.

The actual error:
image

Another question:

Is, it possible to remove this macro: _ ?

@dg
Copy link
Member

dg commented Jun 5, 2020

{_ macro is a historical relic that cannot be removed now due to backward compatibility until version 3.0.

But you can use {=...} to call functions without any restrictions, so for example {=__('Get an estimation', 'domain')}.

@dg dg added this to the v3.0 milestone Jun 5, 2020
@awps
Copy link
Author

awps commented Jun 5, 2020

Oh! Good to know that I can call functions this way. :)
Thank you for your help.

@dg dg closed this as completed in b84bc3a Nov 11, 2020
dg added a commit that referenced this issue Nov 11, 2020
dg added a commit that referenced this issue Nov 12, 2020
dg added a commit that referenced this issue Nov 12, 2020
dg added a commit that referenced this issue Nov 12, 2020
dg added a commit that referenced this issue Nov 14, 2020
dg added a commit that referenced this issue Nov 14, 2020
dg added a commit that referenced this issue Nov 15, 2020
dg added a commit that referenced this issue Nov 15, 2020
dg added a commit that referenced this issue Nov 15, 2020
dg added a commit that referenced this issue Nov 15, 2020
dg added a commit that referenced this issue Nov 15, 2020
dg added a commit that referenced this issue Nov 15, 2020
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

2 participants