Feature: Register custom function handlers on views
Problem Statement
Currently, the Hazaar view system does not provide a unified way to register custom function handlers that can be used across both Smarty templates and legacy PHP templates. This limitation makes it difficult for developers to extend view functionality in a consistent manner. A feature is needed to allow custom function handlers to be set on a view, making them available in both template engines.
Who will benefit?
- Developers who need to define reusable functions within templates.
- Projects that use both Smarty and legacy PHP templates.
- The Hazaar framework, by providing a more flexible and extensible view system.
Benefits and risks
Benefits
- Provides a unified way to register custom functions across multiple template engines.
- Improves code reusability by eliminating duplicate logic in different template systems.
- Enhances flexibility, allowing developers to customize template behavior without modifying core functionality.
Risks
- Potential naming conflicts with existing template functions.
- Needs careful implementation to ensure compatibility between Smarty and PHP templates.
Proposed Solution
- Add a method to the view system (e.g.,
setFunctionHandler($name, $callback)
) to register custom function handlers. - Ensure that registered function handlers are accessible within both Smarty and legacy PHP templates.
- Implement safeguards to prevent function name conflicts.
- Provide documentation and examples to guide developers in using this feature.
Priority/Severity
-
High (This will bring a huge increase in performance/productivity/usability/legislative cover) -
Medium (This will bring a good increase in performance/productivity/usability) -
Low (anything else e.g., trivial, minor improvements)