{"id":15148473,"url":"https://github.com/furkancosgun/abap-template-engine","last_synced_at":"2026-01-28T06:06:08.699Z","repository":{"id":254075911,"uuid":"845177293","full_name":"furkancosgun/ABAP-TEMPLATE-ENGINE","owner":"furkancosgun","description":"This project provides a flexible and powerful template engine for ABAP environments. It supports dynamic template rendering with conditional logic, loops, and partial templates. ","archived":false,"fork":false,"pushed_at":"2024-08-21T06:47:21.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T02:47:28.266Z","etag":null,"topics":["abap","abapgit","sap","template-engine"],"latest_commit_sha":null,"homepage":"","language":"ABAP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/furkancosgun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-20T18:24:35.000Z","updated_at":"2024-08-28T08:43:10.000Z","dependencies_parsed_at":"2024-08-21T09:17:23.643Z","dependency_job_id":null,"html_url":"https://github.com/furkancosgun/ABAP-TEMPLATE-ENGINE","commit_stats":null,"previous_names":["furkancosgun/abap_template_engine","furkancosgun/abap-template-engine"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-TEMPLATE-ENGINE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-TEMPLATE-ENGINE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-TEMPLATE-ENGINE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkancosgun%2FABAP-TEMPLATE-ENGINE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furkancosgun","download_url":"https://codeload.github.com/furkancosgun/ABAP-TEMPLATE-ENGINE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247584060,"owners_count":20962071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abap","abapgit","sap","template-engine"],"created_at":"2024-09-26T13:04:00.756Z","updated_at":"2026-01-28T06:06:08.641Z","avatar_url":"https://github.com/furkancosgun.png","language":"ABAP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ABAP Template Engine\n\nThis project provides a flexible and powerful template engine for ABAP environments. It supports dynamic template rendering with conditional logic, loops, and partial templates. The following examples illustrate how to use various features of the template engine.\n\n## License\nThis project is licensed under the [MIT License](LICENSE). See the LICENSE file for details.\n\n## Contents\n- [Conditional Rendering Example](#conditional-rendering-example)\n- [Loop and Conditional Rendering Example](#loop-and-conditional-rendering-example)\n- [Repeating Content Example](#repeating-content-example)\n- [Repeating Content with Context Example](#repeating-content-with-context-example)\n- [Partial Templates Example](#partial-templates-example)\n\n### Conditional Rendering Example\nThis example demonstrates how to use conditional logic within a template to show different outputs based on a boolean flag.\n\n```abap\n* Define a template with conditional rendering\n  DATA(template) = |\u003c%if is_deleted %\u003e\u003cp\u003e Is Deleted = True \u003c/p\u003e\u003c%endif%\u003e| \u0026\u0026\n                   |\u003c%ifn is_deleted %\u003e\u003cp\u003e Is Deleted = False \u003c/p\u003e\u003c%endifn%\u003e|.\n\n* Create an instance of the template engine with the defined template\n  DATA(lo_template) = zcl_template_engine=\u003ecreate( template = template ).\n\n* Define the context structure\n  TYPES: BEGIN OF lty_context,\n           is_deleted TYPE boolean,\n         END OF lty_context.\n\n* Initialize context with data\n  DATA: ls_context TYPE lty_context VALUE 'X'.\n\n* Render the template with the context\n  cl_demo_output=\u003edisplay( lo_template-\u003erender( ls_context ) ).\n```\n```html\n\u003cp\u003e Is Deleted = True \u003c/p\u003e\n```\n\n### Loop and Conditional Rendering Example\nThis example shows how to render a list of items, applying conditional display based on item properties.\n\n```abap\n* Define a template with a loop and conditional rendering\n  DATA(template) = |\u003c% for item in items %\u003e| \u0026\u0026\n                   |\u003c% if item-show %\u003e| \u0026\u0026\n                   |\u003cp\u003eItem: \u003c%item-name%\u003e\u003c/p\u003e{ cl_abap_char_utilities=\u003enewline }| \u0026\u0026\n                   |\u003c% endif %\u003e| \u0026\u0026\n                   |\u003c% endfor %\u003e|.\n\n* Define the structure for loop items\n  TYPES: BEGIN OF lty_context_line,\n           name TYPE string,\n           show TYPE boolean,\n         END OF lty_context_line.\n\n* Define the main context structure\n  TYPES: BEGIN OF lty_context,\n           items TYPE TABLE OF lty_context_line WITH EMPTY KEY,\n           item  TYPE lty_context_line, \"item required\n         END OF lty_context.\n\n* Initialize context with data\n  DATA: ls_context TYPE lty_context.\n  ls_context-items = VALUE #( ( name = 'Item 1' show = abap_true )\n                              ( name = 'Item 2' show = abap_false )\n                              ( name = 'Item 3' show = abap_true ) ).\n\n* Create an instance of the template engine with the defined template\n  DATA(lo_template) = zcl_template_engine=\u003ecreate( template = template ).\n\n* Render the template with the context\n  cl_demo_output=\u003edisplay( lo_template-\u003erender( ls_context ) ).\n```\n```html\n\u003cp\u003eItem: Item 1\u003c/p\u003e\n\u003cp\u003eItem: Item 3\u003c/p\u003e\n```\n### Repeating Content Example\nThis example demonstrates how to repeat a section of the template a specified number of times.\n\n```abap\n* Define a template to repeat content\n  DATA(template) = |\u003c% do 5 %\u003e\u003cp\u003eHello World\u003c/p\u003e{ cl_abap_char_utilities=\u003enewline }\u003c% enddo %\u003e|.\n\n* Create an instance of the template engine with the defined template\n  DATA(lo_template) = zcl_template_engine=\u003ecreate( template = template ).\n\n* Render the template\n  cl_demo_output=\u003edisplay( lo_template-\u003erender( ) ).\n```\n```html\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n```\n\n### Repeating Content with Context Example\nThis example shows how to use a context variable to control the number of repetitions in the template.\n\n```abap\n* Define the context structure\n  TYPES: BEGIN OF lty_context,\n           count TYPE i,\n         END OF lty_context.\n\n* Initialize context with data\n  DATA: ls_context TYPE lty_context.\n  ls_context-count = 5.\n\n* Define a template to repeat content based on context\n  DATA(template) = |\u003c% do count %\u003e\u003cp\u003eHello World\u003c/p\u003e{ cl_abap_char_utilities=\u003enewline }\u003c% enddo %\u003e|.\n\n* Create an instance of the template engine with the defined template\n  DATA(lo_template) = zcl_template_engine=\u003ecreate( template = template ).\n\n* Render the template with the context\n  cl_demo_output=\u003edisplay( lo_template-\u003erender( ls_context ) ).\n```\n```html\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n\u003cp\u003eHello World\u003c/p\u003e\n```\n### Partial Templates Example\nThis example demonstrates how to use partial templates to modularize and reuse template snippets.\n\n```abap\n* Define partial templates with more descriptive content\n  DATA(lo_partial1) = zcl_template_engine=\u003ecreate(\n      |Greetings from Partial 1! Here is the name provided in the context: \u003c%name%\u003e|\n  ).\n  DATA(lo_partial2) = zcl_template_engine=\u003ecreate(\n      |Hello from Partial 2! The name in the context is: \u003c%name%\u003e|\n  ).\n  DATA(lo_partial3) = zcl_template_engine=\u003ecreate(\n      |Welcome from Partial 3! Name accessed from context: \u003c%name%\u003e|\n  ).\n\n* Define a main template that uses the partial templates\n  DATA(lo_template) = zcl_template_engine=\u003ecreate(\n      |\u003cp\u003eMessage from Partial 1: \u003c%@partial1%\u003e\u003c/p\u003e{ cl_abap_char_utilities=\u003enewline }| \u0026\u0026\n      |\u003cp\u003eMessage from Partial 2: \u003c%@partial2%\u003e\u003c/p\u003e{ cl_abap_char_utilities=\u003enewline }| \u0026\u0026\n      |\u003cp\u003eMessage from Partial 3: \u003c%@partial3%\u003e\u003c/p\u003e{ cl_abap_char_utilities=\u003enewline }| \u0026\u0026\n      |\u003cp\u003eThis is the main layout. The name used here is: \u003c%name%\u003e\u003c/p\u003e|\n  ).\n\n* Define the context structure including partial templates\n  TYPES: BEGIN OF lty_context,\n           partial1 TYPE REF TO zcl_template_engine,\n           partial2 TYPE REF TO zcl_template_engine,\n           partial3 TYPE REF TO zcl_template_engine,\n           name     TYPE string,\n         END OF lty_context.\n\n* Initialize context with data\n  DATA: ls_context TYPE lty_context.\n  ls_context-partial1 = lo_partial1.\n  ls_context-partial2 = lo_partial2.\n  ls_context-partial3 = lo_partial3.\n  ls_context-name     = 'TEMPLATE_ENGINE'.\n\n* Render the main template with the context\n  cl_demo_output=\u003edisplay( lo_template-\u003erender( ls_context ) ).\n```\n```html\n\u003cp\u003eMessage from Partial 1: Greetings from Partial 1! Here is the name provided in the context: TEMPLATE_ENGINE\u003c/p\u003e\n\u003cp\u003eMessage from Partial 2: Hello from Partial 2! The name in the context is: TEMPLATE_ENGINE\u003c/p\u003e\n\u003cp\u003eMessage from Partial 3: Welcome from Partial 3! Name accessed from context: TEMPLATE_ENGINE\u003c/p\u003e\n\u003cp\u003eThis is the main layout. The name used here is: TEMPLATE_ENGINE\u003c/p\u003e\n```\n\nFeel free to adjust any details according to your specific needs or preferences.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurkancosgun%2Fabap-template-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurkancosgun%2Fabap-template-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurkancosgun%2Fabap-template-engine/lists"}