Re: [PHPTAL] Implementing phptal modifiers as static methods in multiple classes
This still initializes all 300 prefixes, while the goal is to initialize them either: 1) on-demand, or 2) by declaring prefixes in page / view / controller classes - for prefixes which are unique for particular template usage However I can see that each prefix registered is not more then an entry in PHPTAL's array with some minimal processing, so maybe it does not worth it to do 1) or 2), and it's enough to register them all together. Currently I have found the way to do it without cracking phptal. Here is what I have so far and it works perfectly: http://pastie.org/2059222 (this class is a tool to use PHPTAL with F3 PHP framework) Regards, Anton Andriyevskyy Business Automation Web Development 2011/6/5 Kornel Lesiński kor...@geekhood.net On Fri, 03 Jun 2011 08:12:19 +0100, Anton Andriyevskyy x.meg...@gmail.com wrote: Currently in PHPTAL I don't think it's possible, but you could easily modify PHPTAL to do it. See PHPTAL_TalesRegistry-findUnregisteredCallback — loop through your classes there. Alternatively, you could register all prefixes, but only before template is compiled. To do it, extend PHPTAL class and: function parse() { // register 300 prefixes here :) return parent::parse(); } This way you won't get performance hit at run time. -- regards, Kornel Lesiński ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Implementing phptal modifiers as static methods in multiple classes
On Fri, 03 Jun 2011 08:12:19 +0100, Anton Andriyevskyy x.meg...@gmail.com wrote: Currently in PHPTAL I don't think it's possible, but you could easily modify PHPTAL to do it. See PHPTAL_TalesRegistry-findUnregisteredCallback — loop through your classes there. Alternatively, you could register all prefixes, but only before template is compiled. To do it, extend PHPTAL class and: function parse() { // register 300 prefixes here :) return parent::parse(); } This way you won't get performance hit at run time. -- regards, Kornel Lesiński ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
[PHPTAL] Implementing phptal modifiers as static methods in multiple classes
Hello. From the source code I can see that I'm able to use modifiers like className.methodName if my class named className implements PHPTAL_Tales. What is bad here is that: 1. I have multiple classes implementing phptal modifiers (for better categorization) and 2. Their names are long *Q1.* Is it possible to register class names to be looked for modifier static methods? So I do not have to write tal:content=className.modifierMethodName: expression but only modifierMethodName: expression. I found that I can use PHPTAL_TalesRegistry-registerPrefix(), but if I have 300 modifiers and I need only few ones on each template - I would not register all them at once. Makes sense? *Q2.* Can this [potential] dynamic search for modifier implementors also work with php class autoloading? Any ideas? So the final usage would be something like: U1. Declare calls with static methods, maybe even phptal_tales_modifier U2. Call PHPTAL_TalesRegistry-getInstance()-registerPrefix(array('myClass1', 'myClass2', ...)); U3. Use my modifiers in templates, having php autoload in place. Regards, Anton Andriyevskyy Business Automation Web Development ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal