REMARK Documentation

Template Tags

Introduction

main uses:

The Template tags are usefull to allow you to easily specify and use different page look and feels.

The typical use is to automatically add header and footer information for each source file, without having to actually include this data within the content pages.

For example, this whole site adds a css refering tag, title, menu header and a footer, thus not one of the source files needs to bother with this redundant data!

Other uses:

TTAGS are also usefull to allow you to wrap any kind of files within remark's engine without having to edit these files in any way.

Just create a ttag which handles them, create an rtag which parses their data, and voila, they are automatically converted to html by remark, and can be dropped in within your site without any further human manipulation. Also remember that they can have header and footer data added automatically... its all free once setup.

How to setup a Template Tag File

Create an html file and save it within any path which is resolved in your global or site configs.

to match any ".txt" files, you simply call the file "txt.ttag".

Its that simple!

What should ttag files actually contain?

If you are simply creating html templates for different looks, just include normal html you wish to use as the basis for all pages of that look.

For example:

<HTML> 
  <HEAD><title> MY WEB SITE </title></HEAD>
  <BODY>
    <CENTER>
      <H1>MY WEB SITE</H1>
    </CENTER>
    <remark-file-data!>
    <HR>
    <CENTER>
      <p!  last updated: <modified!>>
    </CENTER>
  </BODY>
</HTML>

This would define a standard html page with window title preset to your site's name. This default look would also include a simple header on every page and a footer which always includes last file modification date.

Note use of the tag <remark-file-data!> which is defined just below.

The <remark-file-data!> tag

This core tag, simply copies the file data as-is exactly where the <remark-file-data!> tags appears in any page.

be carefull not to include this tag in any source file, as it will effectively create an endless loop, where the source file will attemp to include itself, until you run out of RAM.

How to create different looks for my source html files?

If you create a file called "html.ttag", then, all ".html" files will be using that template for their layout.

If you create a file called "printhtml.ttag", then, any ".printhtml" files will be using that template for their layout.

Thus just save out your source files using different extension names and they will be using different templates.

How do I include non-html source files in my web site?

You must first create an rtag which can parse the file data (usually ascii) and return html text from it. Your best bet is to return remark or reduced html, which can obviously include other document-type specific tags.

You then setup a ttag file, so that remark knows within what rtag it should load the file contents.

here is an example make-doc ttag file:

;------------------------------------------------------
; Obviously, we must have defined the <make-doc!> rtag within our site 
; of global configs, in order for the content to actually be converted to 
; html beforehand...
;------------------------------------------------------
<HTML> 
  <HEAD><title> MY WEB SITE </title></HEAD>
  <BODY>
    <CENTER>
      <H1>MY WEB SITE</H1>
    </CENTER>
    <make-doc! <remark-file-data!>>
    <HR>
    <CENTER>
      <p!  last updated: <modified!>>
    </CENTER>
  </BODY>
</HTML>

here is another example ttag file to load ascii files as-is:

;------------------------------------------------------
; Here we need no rtag, since we simply copy the ascii 
; file within a set of <PRE> </PRE> html tags.
;------------------------------------------------------
<HTML> 
  <HEAD><title> MY WEB SITE </title></HEAD>
  <BODY>
    <CENTER>
      <H1>MY WEB SITE</H1>
    </CENTER>
    <pre> <remark-file-data!> </pre>
    <HR>
    <CENTER>
      <p!  last updated: <modified!>>
    </CENTER>
  </BODY>
</HTML>

output file name?

When the file is going to be written out, remember that its file name will be the same, except that its extension will ALWAYS become .html.

Beware: If you already have a source file with the same name, but with .html extension, then only one of the source files will remain in the destination folder.

an example auto rtag: make-doc

This is a very tempting solution to allow site building tools which incorporate make doc files, and any of your own rebol or custom site building tools.

I will be filling up this section, as soon as the make-doc auto rtag is done, and will be pasting code snippets and source file examples to better illustrate the complete process.




last updated: 16-Feb-2006/16:15:17-5:00