11.3. FrameTextBlock
Aus Hugo Doku
The text of all handled text elements of the .model file can be accessed by a Frame class derived fromFrameTextBlock.
HuGo makes all text elements only available for one FrameTextBlock class. Thus be sure, you only have one class defined per HuGo project. This is not a bug, but sensible to handle all text elements in the same matter. If you want to handle them different, put the text inside a own tag, which you then handle different in a FrameDocu classes.
You do not have to explicitly declare your FrameTextBlock class. HuGo does this automatically. The loading process depends on different factors, thus for you it is not deterministic, which FrameTextBlock class is taken, if there are more than once in your frames directory.
The following files show exemplary the handling of text elements. Imagine you have some tags for documentation within your .model file. As a small example we take a simple paragraph description which should result in corresponding HTML tags.
Example 11.2. Handing of Text Elements
The .model file:
<model>
<doc file="greeting.html">Hallo < strong>HuGo</ strong>!</doc>
</model>
The doc.jxgp file:
package doc_frames;
public class doc extends FrameDocu
{
@#slot doc_text;
public @#String file;
@#gen HTML<!file+".html","gen","HTML"!>
<#html
<html>
<title>A greeting</title>
<body>@#doc_text</body>
</html>
#>
}
The strong.jxgp file:
package doc_frames;
public class strong extends FrameDocu
{
@#slot doc_text;
@#gen doc_text
<#html< b>@#doc_text</ b> #>
}
The textblock.jxgp file:
package doc_frames;
public class textblock extends FrameTextBlock
{
@#gen doc_text
<#cpp@#text#>
}
The generated greeting.html file:
<html>
<title>A greeting</title>
<body>Hallo< b>HuGo</ b>!</body>
</html>
Remarks:
* There is only one class for handling all text elements, the Frame class textblock.
* Every sign written within <#....#> of the @#gen method is generated sign-as-sign including all whitespaces like RETURN. Therefore in the doc_text methods there is not any linebreak, because this would look strange in the generated .html file.
Of course you can as well use XSLT for transforming such a .model file to HTML. But solving the transformation with HuGo is especially very interessting if you have a mixed .model file, where you specify both kind of tags, such which result in source code and as well such for documentation. This is sensible to keep specification for source code and corresponding documentation together. As the target generation depends on what you have written in the @#gen methods, you can e.g. as well generate JavaDoc comments out of it, which are integrated in your generated source code.
Next: 11.4. FrameCommentBlock

