DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24226>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24226

Proposition for new Preprocessor for jsp

           Summary: Proposition for new Preprocessor for jsp
           Product: Tomcat 5
           Version: Unknown
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Enhancement
          Priority: Other
         Component: Unknown
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


Hi There,

I'm a student with experience of creating large applications for tomcat. I 
lately created my own Template Engine, of course exactly the way I want a 
template engine to be. In fact it is a precompiler on the jsp compiler. I would 
like my templateengine to be a standard precompiler of the jsp compiler.

I would appreciate a professional responce very much!

Here follows a copy-paste of the short manual about the usage of the tool and 
the used language:


---------
Template Engine

Usage of the Tool
The tool expects 3 commandline arguments:
-       Base directory of the directory tree containing the templates 
(the “input tree”);
-       Base directory of the directory tree where the generated files should 
be placed (the “output tree”);
-       The extension of the files that the tool should manage, e.g. “.jsp” 
or “.php4”.

In general the tool reads all files in the input tree with the given extension, 
reads and remembers all their definitions and bodies and for every one that is 
not “abstract”, generates a file in the same subdirectory in the output tree. 
The tool also generates new directories if needed,  removes files with the 
given extension if not any more in the input tree and removes directories if 
they just became empty by deleting one or more files.

Definitions and the Usage of definitions
In general the bodies of files and of all sub elements contain just 3 types of 
content:
-       Literal content (output: The content itself);
-       Definitions (output: None);
-       Usages of or references to definitions (output: The content of the 
definition);

All definitions have a name and are referred to using this name. If a file or 
other element refers to some definition it is first searched in that file or 
element itself. If not found it is searched in the element using that element. 
If it is also not found in that one it is searched in the element using that 
one and so on.

Introducing the Language
A File
If a file has “##=abstract” as its very first line, this file is “abstract “ 
and must contain a definitions body. Otherwise it must contain a normal body.

Definitions Body
A definitions body contains only definition statements. Statements end 
with “##’ and are called blocks.
Normal Body
A normal body contains literal content, any kind of statements, and references 
to definitions. All statements start with “<##” and end with “#/>”.
Inline Body
A inline body contains literal content and references to definitions. It is 
delimited by quotes or brackets from any one row of the following table.
Open    Close
{       }
[       ]
(       )
‘     ‘
“     “
<       >
Examples: “’inline body’” and “[another <# inline /> body]”

The Reference to a Definition
A reference starts with “<#”. Then contains the name of the definition referred 
to and may furthermore contain one or more definitions with inline bodies, 
starting with the name, followed by a ‘=’ symbol. If such a definition has 
name “default”, this one is used if the definition referred to is not found. 
Example: “<# definition123 subdef1=”aaa” subdef2=”bbb” default=”default 
defin”/>”.

The Definition Statement
A definition statement adds a definition to the element it appears in. It 
starts with “def”, followed by the name of the definition. If  the line ends it 
must contain a normal body. Otherwise a inline body must follow. Examples: “def 
defin1 ‘body of definition defin1’” and
“def  defin2
    Body of defin2
  [end symbol of statement or block]”

The Include Statement
A include statement is in fact a complex reference. It adds a part to the 
element it appears in which refers to a definition. It starts with “inc”, 
followed by the name of the definition referred to till the end of the line. 
After this line a definitions body must follow. Example: 

“inc  defin2
    def subdef1’ ‘body of subdef1’
    def  subdef2
      Body of subdef2
     ##
  [end symbol of statement or block]”

 
The Defining Include Statement
A defining include statement is the same as a include statement, except that is 
does not add a part to the element it appears in, but adds a definition to that 
element instead. It is a definition type statement. In fact it is the same as a 
definition statement with a normal body containing exactly one include 
statement. A include statement is defining if the name of the definition 
referred to is on the same line followed by “defining” followed by the name of 
the definition it defines. Example:

“inc def1 defining subdef_of_def1
    def subdef1’ ‘body of subdef1’
    def  subdef2
      Body of subdef2
     ##
  [end symbol of statement or block]”


Predefined Definitions
The engine has predefined definitions. A definition defined in a file or 
element may not have a name of a predefined definition.

On this moment the only predefined one is “linkbase”. When this one is used / 
referred to it outputs a relative link prefix to the base of the input / output 
base directory. For example if it is used in a file (in the read base 
dir) “subdir1/subdir2/file.ext”, it outputs “../../”. If it is used in a file 
(in the read base dir) “file.ext”, it outputs nothing. 
Some Examples
Input file / template in the input tree:
<## def d3
  <# centerline />
#/>

<##def d1
  Start of d1
  <##def centerline ‘Centerline of d1’ #/>
  <# d3 />
  End of  d1
#/>

<##def d2
  Start of d2
  <##def centerline ‘Centerline of d2’ #/>
  <# d3 />
  End of  d2
#/>

Start
<# d1 />
<# d2 />
End

Generates a file in the output tree on the same place as the file above:



Start
  Start of d1
    Centerline of d1
  End of  d1
  Start of d2
    Centerline of d2
  End of  d2
End

 
Example of splitting html and jsp.
Input file / template containing the html:
##=abstract

def myTable
  <table border=”1”>
    <##def row ‘<tr><td><# rowcontent /></td></tr>’ #/>
    <# rows />
  </table>
##

Input file / template containing the jsp:
<##inc myTable
  def rows
     <% for(int i=0i<10;i++) { %>
       <# row />
     <% } %>
     <##def rowcontent ‘<%=i%>’ #/>
  ##
#/>

Will together generate one file in the output tree, on the same place as the 
second file above containing:
  <table border=”1”>
         <% for(int i=0i<10;i++) { %>
           <tr><td><%=i%></td></tr>
         <% } %>
  </table>


Mark the correct indent of all lines.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to