From e93012dbfd864ac85df011d66e74f3ca30c20282 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 18 Oct 2024 11:21:08 +0300 Subject: [PATCH] Making it possible to specify custom code and always adding using bhl directive to generated code --- src/bind.inc.php | 2 ++ tpl/codegen_autobind.twig | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/bind.inc.php b/src/bind.inc.php index 5ea33e3..518ec8d 100644 --- a/src/bind.inc.php +++ b/src/bind.inc.php @@ -43,6 +43,8 @@ function codegen( $options['register_class'] = 'BHL_AutoBindings'; if(!isset($options['namespace'])) $options['namespace'] = 'bhl'; + if(!isset($options['custom_code'])) + $options['custom_code'] = ''; if(isset($options['plugins'])) { diff --git a/tpl/codegen_autobind.twig b/tpl/codegen_autobind.twig index ea43fa1..b54659b 100644 --- a/tpl/codegen_autobind.twig +++ b/tpl/codegen_autobind.twig @@ -3,12 +3,15 @@ using System; using System.Collections; using System.Collections.Generic; +using bhl; #if !BHL_FRONT {%- for imp in imports ~%} using {{imp}}; {%- endfor ~%} #endif +{{custom_code}} + {% import "bhl_bind_macro.twig" as macro %} namespace {{namespace}} {