Forum OpenACS Q&A: Templating System : Designer Guide : Tag Reference : Property

The documentation "Property" tag reference page at (localdomain)/doc/acs-templating/tagref/property.html states:

The property tag is used to set display attributes of the page. The contents of the tag may be plain text, static HTML, or a dynamic template that references local data sources. Properties are most commonly used to pass information to a master template, such as a title or logo.

Usage

<master src="master">

<property name="title">My Home Page</property>

<p>Welcome to my home page!</p>

...

/end quote

The meaning seems intuitively clear, but I'm not certain of the usage based on this information. Furthermore, the references to "master" and "slave" tags don't help much, because they seem to repeat the same information. Could someone describe a little more about this tag, perhaps providing Usage, Result.

Maybe its that "My Home Page" is capitalized in one place and the result is in lower case? I am confused...

Hi Torben,

The "My Home Page" within the <property> tags has nothing to do with the "my home page" in the next line (thus, it's a confusing example if you don't know what is going on).

Here's a brief step-by-step (minor changes for clarity)...

Line 1:

<master src="my-master">
This says to the web server: I have a master template and it's called "my-master". Once you're done evaluating all the stuff on my page, go and evaluate everything in the my-master page. There you will find a <slave> tag. Stick all of the output from me into the space occupied by that slave tag. Then return that entire page to the user as the final page.

Line 2:

<property name="title">My Home Page</property>
This tells the web server: Go look in my-master for a variable called title (@title@). Set that variable to "My Home Page". So, the property tag is a way to communicate variables up to the master template. It doesn't affect anything on the rest of the ADP page being evaluated.

So, the following ADP page:


<master src="my-master">
<property name="title">OpenACS rules!</property>
<property name="help-link"><a href="blahblah">Help</a></property>

<p>Welcome!</p>

<p><b>i love templating</b></p>


with the following my-master.adp template:
<html>
<head><title>@title@</title></head>
<body>
<h2>@title@</h2>
<hr>
@help-link@

<slave>

<hr>
</body>
</html>

would create the following HTML document:
<html>
<head><title>OpenACS Rules!</title></head>
<body>
<h2>OpenACS Rules!</h2>
<hr>
<a href="blahblah">Help</a>

<p>Welcome!</p>

<p><b>i love templating</b></p>

<hr>
</body>
</html>

Hope that helps a bit...(and hope all the tags make it through to the bboard properly!)
That's a great explanation, Vinod. I understand now. Thank you!

You should add it to the docs when you get a chance.

And, there is nothing at all stopping you from having the <master> of a <slave> in turn be the <slave> of another <master>, and propogate <property>'ies all the way up the chain.  In fact, the intermediate master(s) can even conditionally modify what properties they pass up depending ones they receive, providing for defaults if the original <slave> doesn't pass anything up.

It's a very handy facility.  As are <include>'s.  😊

And, just as another example, some properties are aggregated up the hierarchy:

ADP:
&lt;property name="header_stuff"&gt;
@header_stuff;noquote@
... some more ...
&lt;/property&gt;

TCL:
if { ![info exists header_stuff] } {
set header_stuff {}
}

(Theres possibly a more beautyful way...)