osalvador / tePLSQL

PL/SQL Template engine
http://osalvador.github.io/tePLSQL/
MIT License
63 stars 18 forks source link

Include multiple templates from a single Directive. #24

Closed MikeKutz closed 6 years ago

MikeKutz commented 7 years ago

The objective is to include multiple, similarly related templates using one directive command. This feature should only apply to templates stored in TE_TEMPLATES.

Suggested syntax change would allow the use of % or * as a wild card for the include directive

Order of inclusion would need to be based on the NAME of the template. This requirement is needed to insure dependent objects are created in the correct order.

Example set of includes:

  <%@ include( mycompany.tapi.types.01_record.specification ) %>
  <%@ include( mycompany.tapi.types.02_associative_array.specification ) %>
  <%@ include( mycompany.tapi.types.03_nested_table.specification ) %>
  <%@ include( mycompany.tapi.types.04_APEX_array.specification ) %>
  <%@ include( mycompany.tapi.types.05_APEX_nested_table.specification ) %>

The enhancement would allow the series of include statements to be simplified to:

  <%@ include( mycompany.tapi.types.%.specification ) %>

This enhancement would also allow the automatic inclusion of new sub-templates. This is useful for quickly adding functions to a Package or UDT.

In turn, a Package specification code can then be simplified to this:

-- template code for "mycompany.tapi.specification"
CREATE OR REPLACE
PACKAGE <%@ include( mycompany.tapi.name ) %>\\n
AS
  <%@ include( mycompany.tapi.pldoc ) %>

  <%@ include( mycompany.tapi.types.%.specification ) %>

  <%@ include( mycompany.tapi.exceptions.%.specification ) %>

  <%@ include( mycompany.tapi.globals.%.specification ) %>

  <%@ include( mycompany.tapi.functions.%.specification ) %>
END;
<%= '/' %>\\n

MK

s-oravec commented 7 years ago

With "globbing" it could be as simple as

-- template code for "mycompany.tapi.specification"
CREATE OR REPLACE
PACKAGE <%@ include( mycompany.tapi.name ) %>\\n
AS
  <%@ include( mycompany.tapi.pldoc ) %>

  <%@ include( mycompany.tapi.**.specification ) %>
END;
<%= '/' %>\\n

Which may include all specifications under mycompany.tapi I would use * instead of % to, so it won't be mistaken with LIKE expression.

MikeKutz commented 7 years ago

syntax question fo s-oravec Is there a particular reason why you used a double star instead of a single star?

clarification of requirement In s-oravec's example, should the globing include all specifications under mycompany.tapi.some.deep.nested.area also?

I'm thinking: no

*`vs%** I agree that the usage of*should be used instead of%. It should make theinclude()syntax easier to read. ( The%seems to add confusion, for me, when reading within the<% %>` brackets)

MK

MikeKutz commented 6 years ago

For simplification, I plan on limiting this enhancement to three(3) globbing modes

Other limitations

MK

MikeKutz commented 6 years ago

I'm adding an additional mode

The others are done. I just need to test the regexp mode and update the README.md file.

MK