Giter VIP home page Giter VIP logo

Comments (6)

wisskid avatar wisskid commented on July 18, 2024

Yes, if you also want the BCPluginsAdapter, you could also do this:

$smarty->setExtensions([
    new Smarty\Extension\CoreExtension(),
    new MyCustomExtension(),
    new Smarty\Extension\DefaultExtension(),
   new Smarty\Extension\BCPluginsAdapter($smarty),
]);

I didn't document that because I thought people who write custom Extensions and insert them before the default ones probably don't need the BCPluginsAdapter anymore.

from smarty.

SlowFox71 avatar SlowFox71 commented on July 18, 2024

Ok.

But am I really supposed to create (yet another) extension, just to register a filter? This seems kind of overkill to me.

from smarty.

wisskid avatar wisskid commented on July 18, 2024

No, you don't need to. But if you are creating a custom extension anyway, why not put everything you need in there?

from smarty.

SlowFox71 avatar SlowFox71 commented on July 18, 2024

The custom extension is created and included in my framework.

One single call in the application using that framework needs a special output filter, and it took me quite a while to figure out why it is ignored.

What else besides the (deprecated?) registerFilter() could be used for the filter?

from smarty.

wisskid avatar wisskid commented on July 18, 2024

Add

	public function getOutputFilters(): array {
		return [ ];
	}

to your MyCustomExtension and return an object that implements \Smarty\Filter\FilterInterface.

For example:

class MyReverseFilter implements \Smarty\Filter\FilterInterface {

	public function filter($code, \Smarty\Template $template) {
		return strrev($code);
	}

}

Btw: you are right about the documentation. It needs more love.

from smarty.

SlowFox71 avatar SlowFox71 commented on July 18, 2024

From a logical point of view MyCustomExtension is the wrong place. Perhaps I'll create a second, controller-specific extension, I'll have to think about it.

from smarty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.