<img SRC="hugo.png" ALT='hugo'>to set the attribute
hugo''. The first assignment uses double quotes to denote the string boundaries, the second one uses single quotes. There is no difference in the functionality between these to kinds of quotes.
Again, like in html, one kind of quotes might show up inside a string, as long as it is quoted with other kind, for example:
<img SRC="quote.png" ALT='"'>
ALT contains a double quote as value.
As you can see in the description of attribute types, hsc distinguisches between string attributes and numeric attributes. Different from most other languages, it requires these to be quoted just like strings. The reason for this seemingly strange convention is that HTML allows attribute names to start with a number, so while other languages can just assume that anything starting with a digit is not a variable name, hsc can not. If an operator requires a numeric argument, it will just take the ``string'' (i.e. quoted) argument and try to convert it to an integer.
<img SRC=hugo.gif ALT=hugo>is also legal. As this can cause problems with (very) old browsers, it might result in message #22, if hsc is configured to. However, the following is not allowed according to the specifications of html:
<img SRC=image/hugo.gif ALT=hugo>
Because of the slash (``
/'') in the value of
SRC, it would
have been required to put it inside quotes. As this is not the case,
message #81 will show up. Although most browsers can cope with
this, and will use a white space or a greater-than (``
>'') as delimiter,
this behavior is not standard.
When the assigned value starts with a bracket (``
(''), it denotes an
expression to be computed before its result is used as new value.
There are several operators you can use for that, and of course you
also can refer to other attributes.
<img SRC=(name+".gif") ALT=(name)>If the attribute
namehas been set to ``
sepp'' before, this will result in
<img SRC="sepp.png" ALT="sepp">
+'' is used to concatenate two values together.
There are two kind of quotes you can use for string constants, namely single quotes (') and double quotes ("). You can use the one inside of the other just as a normal character:
<img SRC="single.png" ALT="a single (') quote"> <img SRC='double.gif' ALT='a double (") quote'>
Note that this is no ``escape mechanism'', the other quote just is treated as a normal character. For the normal user, this should be all you want to know about ``quotes inside quotes''. Freaky ones, read on.
Because of the limitations of html, it is not possible to use both kind of quotes in one value. However, in hsc you could use string concatenation to push both quotes into one value:
<$define sepp:string=("a single (') quote"+' and a double quote (") together')>
The value of sepp then would be >>
a single (') quote
and a double quote (") together<<. Different to html, hsc
doesn't mind about that internally. The trouble starts when you assign
the value later on to an attribute of an HTML tag:
<img SRC="sepp.png" ALT=(sepp)>
Now hsc can't use neither single nor double quotes to assign the value
ALT. To solve that problem, it
uses double quotes to embed the value in and replaces all double quotes inside
by its entity
", thus resulting in:
<img SRC="sepp.png" ALT="a single (') quote and a double quote (") together">
Note that several browsers are too stupid to display this correctly.
This paragraph deals with a feature you probably do not want to use (and understand) before you understood how those macros work. You can skip this part for now and return later.You can easily let an attribute obtain it's value from another attribute. For example, within a tag call you can use an assignment like
hugohas not been defined and assigned a value before, this will result in an error message. Conditional assignments now only assign a value to the target attribute, if the source attribute has been set; in any case, the source attribute must have been defined before (using
<$define>). Simply use a ``
?='' instead of the ``
='' assignment operator:
sepp?=hugoThis becomes handy for such macros which are more or less only extensions of real HTML tags:
<$macro MY-BODY BackGround:uri> <body BackGround?=BackGround"> </$macro>
<MY-BODY> just inserts a
<BODY> tag. But
optionally it can also handle the attribute
But there has not necessarily a
BackGround attribute to
be set when calling
<MY-BODY>. If you do not specify any,
there also will not be one in the call to
the macro has been processed.
<my-body>will result in
<my-body BackGround='image/backgr.png'>will lead to
<body BackGround="image/backgr.png">thus in the second case also adding the attribute
<MY-BODY> would have been declared without conditional
assignment, it could have looked something like:
<$macro MY-BODY BackGround:uri> <body BackGround=(BackGround)> </$macro>If you would try to call it without a
BackGroundpassed, this attribute would have been unset, and the attempt to copy the value of
BackGround=(BackGround)would result in message #23
On the first sight, it might seem that there is only the simple condition ``if attribute is set..'' possible. But no one prevents you from using code like this:
<$define TEXT:color> <$if COND=(awfully complex condition))> <$let TEXT='#123456'> </$if> <my-body TEXT?=TEXT>This also works for
<$define sepp:string> <$define hugo:string> <$if COND=(awfully complex condition)> <$let hugo="hugo-value"> </$if> <$let sepp?=hugo>and you can also use expressions to compute the source attribute. For instance, the last line of the above example also could have been