Feature: Register custom function handlers on views #321

Closed
opened 2025-03-04 22:15:33 +00:00 by jamie · 4 comments
jamie commented 2025-03-04 22:15:33 +00:00 (Migrated from git.hazaar.io)

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

  1. Add a method to the view system (e.g., setFunctionHandler($name, $callback)) to register custom function handlers.
  2. Ensure that registered function handlers are accessible within both Smarty and legacy PHP templates.
  3. Implement safeguards to prevent function name conflicts.
  4. 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)
## 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 1. Add a method to the view system (e.g., `setFunctionHandler($name, $callback)`) to register custom function handlers. 2. Ensure that registered function handlers are accessible within both Smarty and legacy PHP templates. 3. Implement safeguards to prevent function name conflicts. 4. Provide documentation and examples to guide developers in using this feature. ## Priority/Severity - [x] 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)
jamie commented 2025-03-04 22:15:34 +00:00 (Migrated from git.hazaar.io)

assigned to @jamie

assigned to @jamie
jamie commented 2025-03-04 22:15:39 +00:00 (Migrated from git.hazaar.io)

created branch 321-feature-register-custom-function-handlers-on-views to address this issue

created branch [`321-feature-register-custom-function-handlers-on-views`](/hazaar/framework/-/compare/master...321-feature-register-custom-function-handlers-on-views) to address this issue
jamie commented 2025-03-04 22:15:44 +00:00 (Migrated from git.hazaar.io)

mentioned in merge request !203

mentioned in merge request !203
jamie commented 2025-03-05 02:33:07 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 330a089fcb

mentioned in commit 330a089fcbc333651b1c544ca9346a73ec2df631
jamie (Migrated from git.hazaar.io) closed this issue 2025-03-05 02:33:07 +00:00
jamie self-assigned this 2025-09-04 01:14:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/framework#321
No description provided.