Replace¶
replace
tag determine a mechanism of formatting that render engine use for change content of output tags.
In fact faces
is block of html than concatenated to each other with render engine for generate result.
Note
Renderable Commands at last can contains only one replace
tag.
1 2 3 | <replace tagname="bold">
[template]
</replace>
|
Important
The replace
tag has no child tags.
Attributes¶
- tagName
string
[##-notation
Determine key that must find in rendering result for apply formatting.
template html
[##-notation
¶
Determine template that rendering process use it to format output result.
In replace
tag, child elements considered as template
.
Note
For see more Information about [##-notation
,see [## Notation.
Remarks¶
replace
tag apply to face
rendering result if it’s replace
attribute set to true
.
suppose a rendering command
like this:
1 2 3 4 5 6 7 | <basis core="print" datamembername="db.users">
<face>
<a href="/@id">@fname - @lname</a>
</face>
</basis>
|
And suppose rendering result of command is:
1 2 3 | <a href="/1">s.alireza - qamsari</a>
<a href="/2">amir - jalali</a>
<a href="/3">akbar - karimi</a>
|
In first case, we need to add img
tag before each link
.
For do this with replace
tag, change command like this:
1 2 3 4 5 6 7 8 9 10 11 | <basis core="print" datamembername="db.users">
<face>
<a href="/@id">@fname - @lname</a>
</face>
<replace tagname="img">
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
</replace>
</basis>
|
Then change face
for apply replace
to it:
1 2 3 4 5 6 7 8 9 10 11 | <basis core="print" datamembername="db.users">
<face replace="true">
[(img)]<a href="/@id">@fname - @lname </a>
</face>
<replace tagname="img">
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
</replace>
</basis>
|
We first set replace
attribute to true
for apply replace process in generated result of face
.
Then use some specific notation form determine where is place that replace process must apply.
This notation is:
[(name)params]
In this notation, name
determine name of replacement setting that must be used.
This name must be match with tagname
attribute of replace
tag.
Use name because many each command can define more than one replace
tag.
params
use for send extra data as |
separated list to replacement for advanced case.
Generated result is:
1 2 3 4 5 6 7 8 9 10 11 12 | <img src="smiley.gif" alt="Smiley face" height="42" width="42">
<a href="/1" >
s.alireza - qamsari
</a>
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
<a href="/2" >
amir - jalali
</a>
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
<a href="/3" >
akbar - karimi
</a>
|
Now let to see how can send parameters to replace
tag.
Imagine a case that command contains many face
for generate complex result and in all of them use link
tag with same structure.
It is difficult if we want add a css class or apply some change to all of them.
Again we can use replace
tag.
Let change command by adding new replace
tag to it and edit face
tag:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <basis core="print" datamembername="db.users">
<face replace="true">
[(img)] [(a)@id|@fname|@lname]
</face>
<replace tagname="img">
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
</replace>
<replace tagname="a">
<a href="@val1"> @val2 - @val3 </a>
</replace>
</basis>
|
As you see, we add new replace
tag with tagname
set to a
and below template
:
<a href="@val1"> @val2 - @val3 </a>
For use parameters in replace
tag template
use @val[index]
notation.
In this notation index
present position of needed data in parameters list send to replacement process in calling side.
Note
replace
tag parameters detection process use base index 1
.
For example @val1
refer to first parameter passed to replacement process and so on.
In this example for send parameters to replacement process, we use this notation in face
template
:
[(a)@id|@fname|@lname]
In this notation, @id|@fname|@lname
determine list of three parameters that send to replacement as array.
@id
is first element in array, @fname
is second and @lname
is third.
As your guessed ,rendering result is same as before.