REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 6-Feb-2009 Edit History  

REBOL 3 Datatypes: Tag!



Tags are used in HTML and other markup languages to indicate how text fields are to be treated. For example, the tag <;HTML> at the beginning of a file indicates that it should be parsed by the rules of the Hypertext Markup Language. A tag with a forward slash (/), such as <;/HTML>, indicates the closing of the tag.

Tags are a subset of series, and thus can be manipulated as such:

a-tag: <img src="mypic.jpg">
probe a-tag
<img src="mypic.jpg">
append a-tag { alt="My Picture!"}
probe a-tag
<img src="mypic.jpg" alt="My Picture!">


Valid tags begin with an open angle bracket (<) and end with a closing bracket (>). For example:

<a href="index.html">
<img src="mypic.jpg" width="150" height="200">


The to-tag function converts data to the tag! datatype:

probe to-tag "title"

Use [bad-link:functions/build-tag.txt] to construct tags, including their attributes. The [bad-link:functions/build-tag.txt] function takes one argument, a block. In this block, the first word is used as the tag name and the remaining words are processed as attribute value pairs:

probe build-tag [a href]
<a href="">
probe build-tag [
    img src %mypic.jpg width 150 alt "My Picture!"
<img src="mypic.jpg" width="150" alt="My Picture!">


Use tag? to determine whether a value is an tag! datatype.

probe tag? <a href="">

As tags are a subset of the series pseudotype, use series? to check this:

probe series? <a href="">

The form function returns a tag as a string:

probe form <a href="">
{<a href="">}

The mold function returns a tag as a string:

probe mold <a href="">
{<a href="">}

The print function prints a tag to standard output after doing a reform on it:

print <a href="">
<a href="">

  TOC < Back Next > - WIP Wiki Feedback Admin