Rhtml is template to generate html via ERB. It is composed by ruby code to control the html generation and html fragment.
Foreign Rhtml inclusion is provided for reducing maintenance cost by breaking down a big Rhtml into small pieces.
Inclusion operation will be done by putting on the following statements into Rhtml.
| Syntax | Description | Cassiopeia Version |
|---|---|---|
| <!-- include($RHTML_PATH) --> | $RHTML_PATH must be a text indicating template relative/absolute path. | 1.0 or later. |
| <%= include_template($RUBY_CODE, binding) %> | $RUBY_CODE is a piece of ruby code returning template relative/absolute path. | 1.1 or later. |
<!-- embeds template/header.rhtml -->
<!-- include(template/header.rhtml) -->
<!-- Some method common_template is called and embeds it. -->
<%= include_template(common_template('title.rhtml'), binding) %>
Variable save and restore method is provided to protect variable destructive update in an included Rhtml.
| Syntax | Description | Cassiopeia Version |
|---|---|---|
| save_var(:$VARIABLE_NAME, binding) | It pushes the variable named $VARIABLE_NAME onto a stack. | 1.0 or later. |
| restore_var(:$VARIABLE_NAME, binding) | It takes the last variable pushed into a stack and set it to the variable named $VARIABLE_NAME. |
<% name = 'test'
num = 3
save_var(:name, binding) # 'test' is pushed into a stack
save_var(:num, binding) # 3 is pushed into a stack
# Update variables destructively
name = ''
num = 10
%>
<!-- do something -->
<% # restore_var is called in reverse order compared with save_var
restore_var(:num, binding) # 3 is set to num
restore_var(:name, binding) # 'test' is set to name
%>
|
CGI |
CSS |