Layout¶
The layout
tag use for determine root structure of rendering result and add extra tag to beginning or end of result.
Note
Renderable Commands at last can contains only one replace
tag.
If no layout
tag presented, default value is @child
.
1 2 3 | <layout>
[template]
</layout>
|
Important
The layout
tag has no attributes or child tags.
template html
[##-notaion
¶
Determine template that rendering process use it as place holder in empty cell in generate output result.
In layout
tag, child elements considered as template
.
Note
For see more Information about [##-notaion
,see [## Notation
Remarks¶
For generate output in layout
rendering process
, result generated with Rendering command
replace with @child
term of template
.
So for see expected result, @child
term must be exist in layout
tag.
For example suppose command rendering process result is:
1 2 3 4 5 6 7 8 9 10 11 12 | <tr>
<td>s.alireza</td>
<td>qamsari</td>
</tr>
<tr>
<td>amir</td>
<td>jalali</td>
</tr>
<tr>
<td>akbar</td>
<td>karimi</td>
</tr>
|
If in command has layout
tag like this:
1 2 3 4 5 | <layout>
<table>
@child
</table>
</layout>
|
result become:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <table>
<tr>
<td>s.alireza</td>
<td>qamsari</td>
</tr>
<tr>
<td>amir</td>
<td>jalali</td>
</tr>
<tr>
<td>akbar</td>
<td>karimi</td>
</tr>
</table>
|
Examples¶
For learn how to create and run BasisCore Code, see Get start.
Note
For simplicity, we remove unnecessary part of command in examples.
Use Simple Layout¶
In this example, we write simple Print Command command for learn how to config layout.
suppose we want to display list of users with ul
tag like this:
1 2 3 4 5 6 | <span>Userts:</span>
<ul>
<li>s.alireza</li>
<li>amir</li>
<li>akbar</li>
</ul>
|
So start writing a Print Command command like this:
1 2 3 4 5 6 7 | <basis core="print" datamembername="db.users">
<face>
<li>@name</li>
</face>
</basis>
|
If run this command, result is:
1 2 3 | <li>s.alireza</li>
<li>amir</li>
<li>akbar</li>
|
This happen because default value for layout
is @child
and this mains that generated result directly send to output.
the result is not well-formatted or acceptable and ul
tag must add to start and end of rendering result.
So we must use layout
tag for add this format to generated result:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <basis core="print" datamembername="db.users">
<face>
<li>@name</li>
</face>
<layout>
<ul>
@child
</ul>
</layout>
</basis>
|
Now rendering result is:
1 2 3 4 5 | <ul>
<li>s.alireza</li>
<li>amir</li>
<li>akbar</li>
</ul>
|
As you see and described earlier, layout
tag replace @child
term with rendering result and generate new formatted result.
So if @child
removed from layout
tag, rendering result not present in output.
In final step add span
tag to layout
for expected result:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <basis core="print" datamembername="db.users">
<face>
<li>@name</li>
</face>
<layout>
<span>Userts:</span>
<ul>
@child
</ul>
</layout>
</basis>
|
And result is:
1 2 3 4 5 6 | <span>Userts:</span>
<ul>
<li>s.alireza</li>
<li>amir</li>
<li>akbar</li>
</ul>
|