Export (0) Print
Expand All

Replacement Tag 

A replacement tag can be added to a server response file (SRF) to indicate the point at which dynamic content should be inserted into a response. Replacement tags consist of two pairs of braces enclosing the name of a replacement method or a rendering instruction.


{{ [rendering_instruction] [handler_alias.]replacement_method[(argument_data)] }}
{{ rendering_instruction_end }}

rendering_instruction(optional)

A control statement (if, else, or while) that can be used to affect the flow of the rendering. See Remarks for more details.

handler_alias(optional)

The alias of the request handler providing the replacement method identified by replacement_method. If handler_alias is missing, the replacement method must be provided by the handler specified in the handler tag. Otherwise, the request handler is obtained from the corresponding subhandler tag.

replacement_method

The name of the replacement method that will be called to render the tag.

The replacement_method string is mapped to a C++ method call by a REPLACEMENT_METHOD_ENTRY macro in the replacement method map of the request handler class or by a tag_name attribute. The name of this method is limited to ATL_MAX_METHOD_NAME_LEN characters.

argument_data(optional)

The data used to initialize the argument passed to the replacement method. See Passing An Argument To A Replacement Method for more details.

rendering_instruction_end

A control statement (endif or endwhile) used to indicate the end of a processing block. See Remarks for more details.

Use a tag containing only a replacement method to indicate the point at which dynamic content should be inserted into a response.

Use the if, else, and endif rendering instructions to mark blocks of the SRF to be conditionally rendered. If the replacement method in an if tag returns HTTP_SUCCESS, then the content between the if and its matching else or endif tag will be rendered. If the replacement method returns HTTP_S_FALSE, the content in that block will be discarded.

Use the while and endwhile rendering instructions to mark a block of the SRF to be rendered in a loop. While the replacement method in a while tag returns HTTP_SUCCESS, the content between the while and its matching endwhile tag will be repeatedly rendered. The replacement method should return HTTP_S_FALSE to end the while loop.

Note that the content of if or while blocks is not limited to static text. Further replacement tags can be nested in these blocks. The maximum nesting is limited to ATL_MAX_BLOCK_STACK levels.

{{if RenderThis}}
Here is some text
{{endif}}

In this example, the primary request handler's RenderThis method is called. If it returns HTTP_SUCCESS, the text Here is some text is rendered into the response stream. Otherwise, nothing is rendered into the response stream. The if tag and its matching endif tag will be removed from the response stream.

<table>
{{while GetNextBirthday}}
<tr><td>{{GetName}}</td><td>{{GetBirthday}}</td></tr>
{{endwhile}}
</table>

In this example, the primary replacement handler's GetNextBirthday method is called. While that method returns HTTP_SUCCESS, all the HTML in the while block (the table row) is repeatedly rendered. Note that tags have been nested here.

For another example, see the SRFSyntax Sample.

Community Additions

ADD
Show:
© 2014 Microsoft